active_snapshot 0.2.1 → 0.2.4

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.
@@ -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
- assert_raise ArgumentError do
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
  {}
data/test/test_helper.rb CHANGED
@@ -50,7 +50,7 @@ klasses = [
50
50
  ]
51
51
 
52
52
  klasses.each do |klass|
53
- if defined?(SQLite3)
53
+ if klass.connection.adapter_name.downcase.include?("sqlite")
54
54
  ActiveRecord::Base.connection.execute("DELETE FROM #{klass.table_name};")
55
55
  ActiveRecord::Base.connection.execute("UPDATE `sqlite_sequence` SET `seq` = 0 WHERE `name` = '#{klass.table_name}';")
56
56
  else
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.1
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: 2021-08-19 00:00:00.000000000 Z
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
@@ -157,8 +159,6 @@ files:
157
159
  - test/dummy_app/config/boot.rb
158
160
  - test/dummy_app/config/database.yml
159
161
  - test/dummy_app/config/environment.rb
160
- - test/dummy_app/config/environments/development.rb
161
- - test/dummy_app/config/environments/production.rb
162
162
  - test/dummy_app/config/environments/test.rb
163
163
  - test/dummy_app/config/initializers/backtrace_silencers.rb
164
164
  - test/dummy_app/config/initializers/inflections.rb
@@ -186,7 +186,7 @@ licenses:
186
186
  metadata:
187
187
  source_code_uri: https://github.com/westonganger/active_snapshot
188
188
  changelog_uri: https://github.com/westonganger/active_snapshot/blob/master/CHANGELOG.md
189
- post_install_message:
189
+ post_install_message:
190
190
  rdoc_options: []
191
191
  require_paths:
192
192
  - lib
@@ -201,47 +201,47 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
201
  - !ruby/object:Gem::Version
202
202
  version: '0'
203
203
  requirements: []
204
- rubygems_version: 3.1.4
205
- signing_key:
204
+ rubygems_version: 3.2.32
205
+ signing_key:
206
206
  specification_version: 4
207
207
  summary: Dead simple snapshot versioning for ActiveRecord models and associations.
208
208
  test_files:
209
- - test/unit/active_snapshot_test.rb
210
- - test/unit/errors_test.rb
211
- - test/models/snapshots_concern_test.rb
212
- - test/models/snapshot_item_test.rb
213
- - test/models/snapshot_test.rb
214
- - test/test_helper.rb
215
- - test/generators/active_snapshot/install_generator_test.rb
216
- - test/dummy_app/app/models/note.rb
217
- - test/dummy_app/app/models/volatile_post.rb
218
- - test/dummy_app/app/models/comment.rb
219
- - test/dummy_app/app/models/application_record.rb
220
- - test/dummy_app/app/models/post.rb
221
- - test/dummy_app/app/controllers/application_controller.rb
222
- - test/dummy_app/app/views/layouts/application.html.erb
209
+ - test/dummy_app/Rakefile
223
210
  - test/dummy_app/app/assets/config/manifest.js
224
211
  - test/dummy_app/app/assets/javascripts/application.js
225
212
  - 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
229
- - test/dummy_app/config/environments/production.rb
230
- - test/dummy_app/config/environments/development.rb
231
- - test/dummy_app/config/environments/test.rb
232
- - test/dummy_app/config/environment.rb
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
233
222
  - test/dummy_app/config/application.rb
234
- - test/dummy_app/config/database.yml
235
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
236
227
  - test/dummy_app/config/initializers/backtrace_silencers.rb
228
+ - test/dummy_app/config/initializers/inflections.rb
237
229
  - test/dummy_app/config/initializers/mime_types.rb
230
+ - test/dummy_app/config/initializers/secret_token.rb
238
231
  - test/dummy_app/config/initializers/session_store.rb
239
232
  - test/dummy_app/config/initializers/wrap_parameters.rb
240
- - test/dummy_app/config/initializers/secret_token.rb
241
- - test/dummy_app/config/initializers/inflections.rb
233
+ - test/dummy_app/config/locales/en.yml
234
+ - test/dummy_app/config/routes.rb
235
+ - test/dummy_app/config/secrets.yml
242
236
  - test/dummy_app/config.ru
243
- - test/dummy_app/Rakefile
244
- - test/dummy_app/db/test.sqlite3
245
- - test/dummy_app/db/migrate/20210306100122_create_snapshots_tables.rb
246
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
247
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
@@ -1,30 +0,0 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # In the development environment your application's code is reloaded on
5
- # every request. This slows down response time but is perfect for development
6
- # since you don't have to restart the web server when you make code changes.
7
- config.cache_classes = false
8
-
9
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
11
-
12
- # Show full error reports and disable caching
13
- config.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
15
-
16
- # Don't care if the mailer can't send
17
- config.action_mailer.raise_delivery_errors = false
18
-
19
- # Print deprecation notices to the Rails logger
20
- config.active_support.deprecation = :log
21
-
22
- # Only use best-standards-support built into browsers
23
- config.action_dispatch.best_standards_support = :builtin
24
-
25
- # Do not compress assets
26
- config.assets.compress = false
27
-
28
- # Expands the lines which load the assets
29
- config.assets.debug = true
30
- end
@@ -1,60 +0,0 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # Code is not reloaded between requests
5
- config.cache_classes = true
6
-
7
- # Full error reports are disabled and caching is turned on
8
- config.consider_all_requests_local = false
9
- config.action_controller.perform_caching = true
10
-
11
- # Disable Rails's static asset server (Apache or nginx will already do this)
12
- config.serve_static_files = false
13
-
14
- # Compress JavaScripts and CSS
15
- config.assets.compress = true
16
-
17
- # Don't fallback to assets pipeline if a precompiled asset is missed
18
- config.assets.compile = false
19
-
20
- # Generate digests for assets URLs
21
- config.assets.digest = true
22
-
23
- # Defaults to Rails.root.join("public/assets")
24
- # config.assets.manifest = YOUR_PATH
25
-
26
- # Specifies the header that your server uses for sending files
27
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
29
-
30
- # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
- # config.force_ssl = true
32
-
33
- # See everything in the log (default is :info)
34
- # config.log_level = :debug
35
-
36
- # Use a different logger for distributed setups
37
- # config.logger = SyslogLogger.new
38
-
39
- # Use a different cache store in production
40
- # config.cache_store = :mem_cache_store
41
-
42
- # Enable serving of images, stylesheets, and JavaScripts from an asset server
43
- # config.action_controller.asset_host = "http://assets.example.com"
44
-
45
- # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
46
- # config.assets.precompile += %w( search.js )
47
-
48
- # Disable delivery errors, bad email addresses will be ignored
49
- # config.action_mailer.raise_delivery_errors = false
50
-
51
- # Enable threaded mode
52
- # config.threadsafe!
53
-
54
- # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
55
- # the I18n.default_locale when a translation can not be found)
56
- config.i18n.fallbacks = true
57
-
58
- # Send deprecation notices to registered listeners
59
- config.active_support.deprecation = :notify
60
- end