fixture_bot 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/lib/fixture_bot/fixture_creator.rb +3 -3
- data/lib/fixture_bot/version.rb +1 -1
- data/lib/fixture_bot.rb +1 -24
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c090d89db0fe2e63c56401037ff83f750698a65da7f0dcb8757636771e5bfccb
|
4
|
+
data.tar.gz: fc46b4fc5ed110c42e5fd12299759d5f31fee318d927e401b0567b2ceed75409
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27e0ef47c063f9600e4844bf8e45025505bf46899eb1c99d1d5ae2527b4f674f75a1d903f8b24fda7d52a11a19b10e395f3dbe210d179e2750ccc749c32a1993
|
7
|
+
data.tar.gz: 0cbd7666b9391ee5c1b78a49393040dcb25171d30e3ad5e382cf0a515818afbbb0ff60591e6f7dd5d7521bcfc3e8cfab32b9663bf50a61565e465a5a91aab26d
|
data/Gemfile
CHANGED
@@ -56,16 +56,16 @@ module FixtureBot
|
|
56
56
|
record_ids[table][name] ||=
|
57
57
|
begin
|
58
58
|
model = instance_eval(&)
|
59
|
-
[model.class.name, model.id]
|
59
|
+
[model.class.name, model.id, model.class.table_name]
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
private def fixture_with_id(table, name, &)
|
64
|
-
_, record_id = fixture(table, name, &)
|
64
|
+
_, record_id, db_table_name = fixture(table, name, &)
|
65
65
|
|
66
66
|
if ::ActiveRecord::Base.connection.respond_to?(:postgresql_version)
|
67
67
|
::ActiveRecord::Base.connection.execute <<~SQL
|
68
|
-
SELECT setval(pg_get_serial_sequence('#{
|
68
|
+
SELECT setval(pg_get_serial_sequence('#{db_table_name}', 'id'), GREATEST(#{record_id}, nextval(pg_get_serial_sequence('#{db_table_name}', 'id'))))
|
69
69
|
SQL
|
70
70
|
end
|
71
71
|
end
|
data/lib/fixture_bot/version.rb
CHANGED
data/lib/fixture_bot.rb
CHANGED
@@ -28,7 +28,7 @@ module FixtureBot
|
|
28
28
|
else
|
29
29
|
colored_output "Full load fixtures"
|
30
30
|
|
31
|
-
|
31
|
+
ActiveRecord::Tasks::DatabaseTasks.truncate_all
|
32
32
|
load_models
|
33
33
|
define_fixture_helpers
|
34
34
|
FixtureBot::FixtureCreator.load_to_db
|
@@ -56,7 +56,6 @@ module FixtureBot
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def caching_max_mtime_fixtures(dump_record_ids)
|
59
|
-
truncate_tables(["__fixture_bot_cache_v1"])
|
60
59
|
connection.execute <<-SQL
|
61
60
|
INSERT INTO __fixture_bot_cache_v1 VALUES ('#{max_mtime_fixtures.iso8601(6)}', '#{Base64.encode64(dump_record_ids)}')
|
62
61
|
SQL
|
@@ -74,32 +73,10 @@ module FixtureBot
|
|
74
73
|
::FactoryBot::SyntaxRunner.include(::FixtureBot::Helpers)
|
75
74
|
end
|
76
75
|
|
77
|
-
RESERVED_TABLES = %w[
|
78
|
-
ar_internal_metadata
|
79
|
-
schema_migrations
|
80
|
-
].freeze
|
81
|
-
|
82
|
-
def clean_db
|
83
|
-
connection.disable_referential_integrity do
|
84
|
-
connection.execute(truncate_tables(connection.tables - RESERVED_TABLES))
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
76
|
def connection
|
89
77
|
::ActiveRecord::Base.connection
|
90
78
|
end
|
91
79
|
|
92
|
-
def truncate_tables(tables)
|
93
|
-
case connection.adapter_name
|
94
|
-
when "SQLite"
|
95
|
-
tables.map { |table| "DELETE FROM #{connection.quote_table_name(table)}" }.join(";")
|
96
|
-
when "PostgreSQL"
|
97
|
-
"TRUNCATE TABLE #{tables.map { |table| connection.quote_table_name(table) }.join(',')} RESTART IDENTITY CASCADE"
|
98
|
-
else
|
99
|
-
"TRUNCATE TABLE #{tables.map { |table| connection.quote_table_name(table) }.join(',')}"
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
80
|
def colored_output(text)
|
104
81
|
puts "\e[33m#{text}\e[0m"
|
105
82
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fixture_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ermolaev Andrey
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|