active_snapshot 0.1.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -2
- data/README.md +10 -5
- data/Rakefile +24 -22
- data/lib/active_snapshot/models/concerns/snapshots_concern.rb +20 -6
- data/lib/active_snapshot/models/snapshot.rb +3 -3
- data/lib/active_snapshot/models/snapshot_item.rb +3 -3
- data/lib/active_snapshot/version.rb +1 -1
- data/lib/generators/active_snapshot/install/templates/create_snapshots_tables.rb.erb +3 -3
- data/test/dummy_app/app/models/note.rb +5 -0
- data/test/dummy_app/app/models/post.rb +4 -1
- data/test/dummy_app/config/database.yml +7 -7
- data/test/dummy_app/config/environments/test.rb +2 -2
- data/test/dummy_app/db/migrate/20210128155312_set_up_test_tables.rb +8 -0
- data/test/dummy_app/db/migrate/{20210306070749_create_snapshots_tables.rb → 20210306100122_create_snapshots_tables.rb} +3 -3
- data/test/dummy_app/db/test.sqlite3 +0 -0
- data/test/dummy_app/log/test.log +1987 -46715
- data/test/models/snapshot_test.rb +1 -1
- data/test/models/snapshots_concern_test.rb +10 -1
- data/test/unit/active_snapshot_test.rb +2 -6
- metadata +40 -24
- data/test/dummy_app/log/development.log +0 -9
@@ -73,7 +73,6 @@ class SnapshotsConcernTest < ActiveSupport::TestCase
|
|
73
73
|
[],
|
74
74
|
[:foobar, 123],
|
75
75
|
{foo: :bar},
|
76
|
-
{foo: {}},
|
77
76
|
{foo: {records: 'bar', delete_method: 'bar'}},
|
78
77
|
]
|
79
78
|
|
@@ -90,6 +89,8 @@ class SnapshotsConcernTest < ActiveSupport::TestCase
|
|
90
89
|
valid = [
|
91
90
|
{},
|
92
91
|
{foo: []},
|
92
|
+
{foo: {}},
|
93
|
+
{foo: Post.limit(1)},
|
93
94
|
{foo: [:foobar, 123]},
|
94
95
|
{foo: {record: 'bar'}},
|
95
96
|
{foo: {records: 'bar'}},
|
@@ -97,6 +98,8 @@ class SnapshotsConcernTest < ActiveSupport::TestCase
|
|
97
98
|
{foo: {records: Post.limit(1) }},
|
98
99
|
{foo: {records: [], delete_method: ->(){} }},
|
99
100
|
{foo: {records: [], delete_method: proc{} }},
|
101
|
+
{foo: nil},
|
102
|
+
{foo: {records: nil}},
|
100
103
|
]
|
101
104
|
|
102
105
|
valid.each do |x|
|
@@ -106,6 +109,12 @@ class SnapshotsConcernTest < ActiveSupport::TestCase
|
|
106
109
|
|
107
110
|
klass.new.children_to_snapshot
|
108
111
|
end
|
112
|
+
|
113
|
+
klass.has_snapshot_children do
|
114
|
+
{foo: {records: 'bar'}, baz: {records: 'barbaz'}}
|
115
|
+
end
|
116
|
+
|
117
|
+
assert klass.new.children_to_snapshot.count == 2
|
109
118
|
end
|
110
119
|
|
111
120
|
end
|
@@ -22,16 +22,12 @@ class ActiveSnapshotTest < ActiveSupport::TestCase
|
|
22
22
|
child = parent.comments.create!(content: :foo)
|
23
23
|
original_child_updated_at = child.updated_at
|
24
24
|
|
25
|
-
orig_comments_size = parent.children_to_snapshot[:comments][:records].count
|
26
|
-
|
27
25
|
assert_difference ->{ ActiveSnapshot::Snapshot.count }, 1 do
|
28
|
-
assert_difference ->{ ActiveSnapshot::SnapshotItem.count },
|
26
|
+
assert_difference ->{ ActiveSnapshot::SnapshotItem.count }, 2 do
|
29
27
|
@snapshot = parent.create_snapshot!(identifier)
|
30
28
|
end
|
31
29
|
end
|
32
30
|
|
33
|
-
assert_equal (orig_comments_size+1), @snapshot.snapshot_items.size
|
34
|
-
|
35
31
|
parent.update_columns(updated_at: 1.day.from_now)
|
36
32
|
|
37
33
|
parent.update_columns(updated_at: 1.day.from_now)
|
@@ -51,7 +47,7 @@ class ActiveSnapshotTest < ActiveSupport::TestCase
|
|
51
47
|
|
52
48
|
parent.reload
|
53
49
|
|
54
|
-
assert_equal
|
50
|
+
assert_equal 1, parent.children_to_snapshot[:comments][:records].count
|
55
51
|
|
56
52
|
### Test Data Chang
|
57
53
|
assert_time_match original_parent_updated_at, parent.updated_at
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_snapshot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Weston Ganger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: appraisal
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: warning
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,6 +148,7 @@ files:
|
|
134
148
|
- test/dummy_app/app/controllers/application_controller.rb
|
135
149
|
- test/dummy_app/app/models/application_record.rb
|
136
150
|
- test/dummy_app/app/models/comment.rb
|
151
|
+
- test/dummy_app/app/models/note.rb
|
137
152
|
- test/dummy_app/app/models/post.rb
|
138
153
|
- test/dummy_app/app/models/volatile_post.rb
|
139
154
|
- test/dummy_app/app/views/layouts/application.html.erb
|
@@ -155,8 +170,8 @@ files:
|
|
155
170
|
- test/dummy_app/config/routes.rb
|
156
171
|
- test/dummy_app/config/secrets.yml
|
157
172
|
- test/dummy_app/db/migrate/20210128155312_set_up_test_tables.rb
|
158
|
-
- test/dummy_app/db/migrate/
|
159
|
-
- test/dummy_app/
|
173
|
+
- test/dummy_app/db/migrate/20210306100122_create_snapshots_tables.rb
|
174
|
+
- test/dummy_app/db/test.sqlite3
|
160
175
|
- test/dummy_app/log/test.log
|
161
176
|
- test/generators/active_snapshot/install_generator_test.rb
|
162
177
|
- test/models/snapshot_item_test.rb
|
@@ -186,46 +201,47 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
201
|
- !ruby/object:Gem::Version
|
187
202
|
version: '0'
|
188
203
|
requirements: []
|
189
|
-
rubygems_version: 3.1.
|
204
|
+
rubygems_version: 3.1.4
|
190
205
|
signing_key:
|
191
206
|
specification_version: 4
|
192
207
|
summary: Dead simple snapshot versioning for ActiveRecord models and associations.
|
193
208
|
test_files:
|
209
|
+
- test/unit/active_snapshot_test.rb
|
210
|
+
- test/unit/errors_test.rb
|
194
211
|
- test/models/snapshots_concern_test.rb
|
195
212
|
- test/models/snapshot_item_test.rb
|
196
213
|
- test/models/snapshot_test.rb
|
197
214
|
- test/test_helper.rb
|
198
|
-
- test/
|
199
|
-
- test/
|
200
|
-
- test/dummy_app/app/models/comment.rb
|
215
|
+
- test/generators/active_snapshot/install_generator_test.rb
|
216
|
+
- test/dummy_app/app/models/note.rb
|
201
217
|
- test/dummy_app/app/models/volatile_post.rb
|
218
|
+
- test/dummy_app/app/models/comment.rb
|
202
219
|
- test/dummy_app/app/models/application_record.rb
|
203
220
|
- test/dummy_app/app/models/post.rb
|
221
|
+
- test/dummy_app/app/controllers/application_controller.rb
|
204
222
|
- test/dummy_app/app/views/layouts/application.html.erb
|
205
|
-
- test/dummy_app/app/assets/stylesheets/application.css
|
206
223
|
- test/dummy_app/app/assets/config/manifest.js
|
207
224
|
- test/dummy_app/app/assets/javascripts/application.js
|
208
|
-
- test/dummy_app/app/
|
209
|
-
- test/dummy_app/config.
|
210
|
-
- test/dummy_app/
|
211
|
-
- test/dummy_app/
|
212
|
-
- test/dummy_app/config/database.yml
|
225
|
+
- test/dummy_app/app/assets/stylesheets/application.css
|
226
|
+
- test/dummy_app/config/secrets.yml
|
227
|
+
- test/dummy_app/config/routes.rb
|
228
|
+
- test/dummy_app/config/locales/en.yml
|
213
229
|
- test/dummy_app/config/environments/production.rb
|
214
|
-
- test/dummy_app/config/environments/test.rb
|
215
230
|
- test/dummy_app/config/environments/development.rb
|
216
|
-
- test/dummy_app/config/
|
231
|
+
- test/dummy_app/config/environments/test.rb
|
217
232
|
- test/dummy_app/config/environment.rb
|
218
|
-
- test/dummy_app/config/
|
233
|
+
- test/dummy_app/config/application.rb
|
234
|
+
- test/dummy_app/config/database.yml
|
219
235
|
- test/dummy_app/config/boot.rb
|
220
|
-
- test/dummy_app/config/initializers/
|
221
|
-
- test/dummy_app/config/initializers/inflections.rb
|
236
|
+
- test/dummy_app/config/initializers/backtrace_silencers.rb
|
222
237
|
- test/dummy_app/config/initializers/mime_types.rb
|
223
238
|
- test/dummy_app/config/initializers/session_store.rb
|
224
239
|
- test/dummy_app/config/initializers/wrap_parameters.rb
|
225
|
-
- test/dummy_app/config/initializers/
|
226
|
-
- test/dummy_app/config/
|
227
|
-
- test/dummy_app/config
|
240
|
+
- test/dummy_app/config/initializers/secret_token.rb
|
241
|
+
- test/dummy_app/config/initializers/inflections.rb
|
242
|
+
- test/dummy_app/config.ru
|
228
243
|
- test/dummy_app/Rakefile
|
244
|
+
- test/dummy_app/db/test.sqlite3
|
245
|
+
- test/dummy_app/db/migrate/20210306100122_create_snapshots_tables.rb
|
229
246
|
- test/dummy_app/db/migrate/20210128155312_set_up_test_tables.rb
|
230
|
-
- test/dummy_app/
|
231
|
-
- test/generators/active_snapshot/install_generator_test.rb
|
247
|
+
- test/dummy_app/log/test.log
|
@@ -1,9 +0,0 @@
|
|
1
|
-
[1m[35m (1.2ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
2
|
-
[1m[35m (4.6ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)[0m
|
3
|
-
[1m[35m (3.9ms)[0m [1m[35mCREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL)[0m
|
4
|
-
[1m[36mActiveRecord::InternalMetadata Load (0.2ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?[0m [["key", "environment"], ["LIMIT", 1]]
|
5
|
-
[1m[35m (0.1ms)[0m [1m[36mbegin transaction[0m
|
6
|
-
[1m[36mActiveRecord::InternalMetadata Create (0.2ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?)[0m [["key", "environment"], ["value", "development"], ["created_at", "2020-10-18 23:26:12.753133"], ["updated_at", "2020-10-18 23:26:12.753133"]]
|
7
|
-
[1m[35m (2.1ms)[0m [1m[36mcommit transaction[0m
|
8
|
-
[1m[35m (0.1ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
9
|
-
[1m[35m (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|