active_snapshot 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -3
- data/README.md +1 -1
- data/lib/active_snapshot/models/concerns/snapshots_concern.rb +1 -3
- data/lib/active_snapshot/models/snapshot.rb +1 -1
- data/lib/active_snapshot/version.rb +1 -1
- data/test/dummy_app/app/models/parent_without_children.rb +5 -0
- data/test/dummy_app/app/models/sub_post.rb +11 -0
- data/test/dummy_app/db/test.sqlite3 +0 -0
- data/test/dummy_app/log/test.log +2463 -1181
- data/test/models/snapshot_test.rb +31 -0
- data/test/models/snapshots_concern_test.rb +1 -3
- metadata +35 -31
@@ -106,4 +106,35 @@ class SnapshotTest < ActiveSupport::TestCase
|
|
106
106
|
assert children_hash.all?{|k,v| v.all?{|x| x.readonly?} }
|
107
107
|
end
|
108
108
|
|
109
|
+
def test_fetch_reified_items_with_sti_class
|
110
|
+
post = SubPost.create!(a: 1, b: 2)
|
111
|
+
comment_content = 'Example comment'
|
112
|
+
post.comments.create!(content: comment_content)
|
113
|
+
post.create_snapshot!('v1')
|
114
|
+
snapshot = post.snapshots.first
|
115
|
+
reified_items = snapshot.fetch_reified_items
|
116
|
+
|
117
|
+
assert_equal post, reified_items.first
|
118
|
+
assert reified_items.first.readonly?
|
119
|
+
assert_equal comment_content, reified_items.second[:comments].first.content
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_single_model_snapshots_without_children
|
123
|
+
instance = ParentWithoutChildren.create!({a: 1, b: 2})
|
124
|
+
|
125
|
+
previous_attributes = instance.attributes
|
126
|
+
|
127
|
+
instance.create_snapshot!('v1')
|
128
|
+
|
129
|
+
instance.update!(a: 9, b: 9)
|
130
|
+
|
131
|
+
snapshot = instance.snapshots.first
|
132
|
+
|
133
|
+
reified_items = snapshot.fetch_reified_items
|
134
|
+
|
135
|
+
assert_equal [instance, {}], reified_items
|
136
|
+
|
137
|
+
assert_equal previous_attributes, reified_items.first.attributes
|
138
|
+
end
|
139
|
+
|
109
140
|
end
|
@@ -52,9 +52,7 @@ class SnapshotsConcernTest < ActiveSupport::TestCase
|
|
52
52
|
def test_has_snapshot_children
|
53
53
|
klass = VolatilePost
|
54
54
|
|
55
|
-
|
56
|
-
klass.has_snapshot_children
|
57
|
-
end
|
55
|
+
assert_nil klass.has_snapshot_children
|
58
56
|
|
59
57
|
klass.has_snapshot_children do
|
60
58
|
{}
|
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.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Weston Ganger
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -149,7 +149,9 @@ files:
|
|
149
149
|
- test/dummy_app/app/models/application_record.rb
|
150
150
|
- test/dummy_app/app/models/comment.rb
|
151
151
|
- test/dummy_app/app/models/note.rb
|
152
|
+
- test/dummy_app/app/models/parent_without_children.rb
|
152
153
|
- test/dummy_app/app/models/post.rb
|
154
|
+
- test/dummy_app/app/models/sub_post.rb
|
153
155
|
- test/dummy_app/app/models/volatile_post.rb
|
154
156
|
- test/dummy_app/app/views/layouts/application.html.erb
|
155
157
|
- test/dummy_app/config.ru
|
@@ -184,7 +186,7 @@ licenses:
|
|
184
186
|
metadata:
|
185
187
|
source_code_uri: https://github.com/westonganger/active_snapshot
|
186
188
|
changelog_uri: https://github.com/westonganger/active_snapshot/blob/master/CHANGELOG.md
|
187
|
-
post_install_message:
|
189
|
+
post_install_message:
|
188
190
|
rdoc_options: []
|
189
191
|
require_paths:
|
190
192
|
- lib
|
@@ -199,45 +201,47 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
201
|
- !ruby/object:Gem::Version
|
200
202
|
version: '0'
|
201
203
|
requirements: []
|
202
|
-
rubygems_version: 3.
|
203
|
-
signing_key:
|
204
|
+
rubygems_version: 3.2.32
|
205
|
+
signing_key:
|
204
206
|
specification_version: 4
|
205
207
|
summary: Dead simple snapshot versioning for ActiveRecord models and associations.
|
206
208
|
test_files:
|
207
|
-
- test/
|
208
|
-
- test/unit/errors_test.rb
|
209
|
-
- test/models/snapshots_concern_test.rb
|
210
|
-
- test/models/snapshot_item_test.rb
|
211
|
-
- test/models/snapshot_test.rb
|
212
|
-
- test/test_helper.rb
|
213
|
-
- test/generators/active_snapshot/install_generator_test.rb
|
214
|
-
- test/dummy_app/app/models/note.rb
|
215
|
-
- test/dummy_app/app/models/volatile_post.rb
|
216
|
-
- test/dummy_app/app/models/comment.rb
|
217
|
-
- test/dummy_app/app/models/application_record.rb
|
218
|
-
- test/dummy_app/app/models/post.rb
|
219
|
-
- test/dummy_app/app/controllers/application_controller.rb
|
220
|
-
- test/dummy_app/app/views/layouts/application.html.erb
|
209
|
+
- test/dummy_app/Rakefile
|
221
210
|
- test/dummy_app/app/assets/config/manifest.js
|
222
211
|
- test/dummy_app/app/assets/javascripts/application.js
|
223
212
|
- test/dummy_app/app/assets/stylesheets/application.css
|
224
|
-
- test/dummy_app/
|
225
|
-
- test/dummy_app/
|
226
|
-
- test/dummy_app/
|
227
|
-
- test/dummy_app/
|
228
|
-
- test/dummy_app/
|
213
|
+
- test/dummy_app/app/controllers/application_controller.rb
|
214
|
+
- test/dummy_app/app/models/application_record.rb
|
215
|
+
- test/dummy_app/app/models/comment.rb
|
216
|
+
- test/dummy_app/app/models/note.rb
|
217
|
+
- test/dummy_app/app/models/parent_without_children.rb
|
218
|
+
- test/dummy_app/app/models/post.rb
|
219
|
+
- test/dummy_app/app/models/sub_post.rb
|
220
|
+
- test/dummy_app/app/models/volatile_post.rb
|
221
|
+
- test/dummy_app/app/views/layouts/application.html.erb
|
229
222
|
- test/dummy_app/config/application.rb
|
230
|
-
- test/dummy_app/config/database.yml
|
231
223
|
- test/dummy_app/config/boot.rb
|
224
|
+
- test/dummy_app/config/database.yml
|
225
|
+
- test/dummy_app/config/environment.rb
|
226
|
+
- test/dummy_app/config/environments/test.rb
|
232
227
|
- test/dummy_app/config/initializers/backtrace_silencers.rb
|
228
|
+
- test/dummy_app/config/initializers/inflections.rb
|
233
229
|
- test/dummy_app/config/initializers/mime_types.rb
|
230
|
+
- test/dummy_app/config/initializers/secret_token.rb
|
234
231
|
- test/dummy_app/config/initializers/session_store.rb
|
235
232
|
- test/dummy_app/config/initializers/wrap_parameters.rb
|
236
|
-
- test/dummy_app/config/
|
237
|
-
- test/dummy_app/config/
|
233
|
+
- test/dummy_app/config/locales/en.yml
|
234
|
+
- test/dummy_app/config/routes.rb
|
235
|
+
- test/dummy_app/config/secrets.yml
|
238
236
|
- test/dummy_app/config.ru
|
239
|
-
- test/dummy_app/Rakefile
|
240
|
-
- test/dummy_app/db/test.sqlite3
|
241
|
-
- test/dummy_app/db/migrate/20210306100122_create_snapshots_tables.rb
|
242
237
|
- test/dummy_app/db/migrate/20210128155312_set_up_test_tables.rb
|
238
|
+
- test/dummy_app/db/migrate/20210306100122_create_snapshots_tables.rb
|
239
|
+
- test/dummy_app/db/test.sqlite3
|
243
240
|
- test/dummy_app/log/test.log
|
241
|
+
- test/generators/active_snapshot/install_generator_test.rb
|
242
|
+
- test/models/snapshot_item_test.rb
|
243
|
+
- test/models/snapshot_test.rb
|
244
|
+
- test/models/snapshots_concern_test.rb
|
245
|
+
- test/test_helper.rb
|
246
|
+
- test/unit/active_snapshot_test.rb
|
247
|
+
- test/unit/errors_test.rb
|