active_snapshot 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53379fe97d90039d39726c0e28a3a4fd114348095de7579da5310c3216ea88f4
4
- data.tar.gz: 1e43163c487ea00d5523c4871ee9a633f9a1d05d4e6a5068e2c94ea959784968
3
+ metadata.gz: aa10e744bf82bbd9037fc6965450546800d9688f9c34aa89cafb952b0d28abf9
4
+ data.tar.gz: 6b142e6e221584c579291a6c25744d2b1fef0264d66f8b3cc209ff903a67ecd6
5
5
  SHA512:
6
- metadata.gz: 125495f59499cb7c4ff2902919525d28aa9587f6b1af6199037abf8e25ab04b56eb4ec8b6d3b5759e5aec6d6d2afa7f30848bee9aeafa9c97721b2c40b54ec0c
7
- data.tar.gz: 7a4c09b48ef78a0402e303a5da2349f01338fa40790cad4b0ff077828528d491df8184dbadfe4cbf1b5f29de5816b4721279386be6020ce29691d03784e1064f
6
+ metadata.gz: 51fa1393301eebb25e05a829f944a08ef90c714ecd4da759a709cf6e9648175cbf758e8e699c4e43fe973ad3c4227379c3e3a123d49f6b57352b0ce6ee5e1b28
7
+ data.tar.gz: f9ee1f4a4a7f2386a4854f337fad374b22226c2f9bbdb57cb47989859b9729d0251d403ed900c41dbe392525a02fc02d1c1392d87308c328809e8b7d299f91de
data/CHANGELOG.md CHANGED
@@ -2,9 +2,13 @@ CHANGELOG
2
2
  ---------
3
3
 
4
4
  - **Unreleased**
5
- * [View Diff](https://github.com/westonganger/active_snapshot/compare/v0.1.0...master)
5
+ * [View Diff](https://github.com/westonganger/active_snapshot/compare/v0.2.0...master)
6
6
  * Nothing yet
7
7
 
8
+ - **v0.2.0** - May 7, 2021
9
+ * [PR #1](https://github.com/westonganger/active_snapshot/pull/1) - Fix bug where only the first child association would be captured
10
+ * [View Diff](https://github.com/westonganger/active_snapshot/compare/v0.1.1...v0.2.0)
11
+
8
12
  - **v0.1.1** - Mar 5, 2021
9
13
  * Switch from JSON to Text because Mysql2 has errors with active_record-import and JSON objects
10
14
  * Fix test suite
@@ -101,9 +101,9 @@ module ActiveSnapshot
101
101
  else
102
102
  raise ArgumentError.new("Invalid `has_snapshot_children` definition. Invalid :records argument. Must be a Hash or Array")
103
103
  end
104
-
105
- return snapshot_children
106
104
  end
105
+
106
+ return snapshot_children
107
107
  end
108
108
  end
109
109
 
@@ -1,3 +1,3 @@
1
1
  module ActiveSnapshot
2
- VERSION = "0.1.1".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
@@ -0,0 +1,5 @@
1
+ class Note < ActiveRecord::Base
2
+ include ActiveSnapshot
3
+
4
+ belongs_to :post
5
+ end
@@ -2,12 +2,14 @@ class Post < ActiveRecord::Base
2
2
  include ActiveSnapshot
3
3
 
4
4
  has_many :comments
5
+ has_many :notes
5
6
 
6
7
  has_snapshot_children do
7
- instance = self.class.includes(:comments).find(id)
8
+ instance = self.class.includes(:comments, :notes).find(id)
8
9
 
9
10
  {
10
11
  comments: instance.comments,
12
+ notes: instance.notes,
11
13
  }
12
14
  end
13
15
  end
@@ -14,6 +14,14 @@ class SetUpTestTables < ActiveRecord::Migration::Current
14
14
 
15
15
  t.timestamps
16
16
  end
17
+
18
+ create_table :notes do |t|
19
+ t.string :body
20
+
21
+ t.references :post
22
+
23
+ t.timestamps
24
+ end
17
25
  end
18
26
 
19
27
  end
@@ -106,6 +106,12 @@ class SnapshotsConcernTest < ActiveSupport::TestCase
106
106
 
107
107
  klass.new.children_to_snapshot
108
108
  end
109
+
110
+ klass.has_snapshot_children do
111
+ {foo: {records: 'bar'}, baz: {records: 'barbaz'}}
112
+ end
113
+
114
+ assert klass.new.children_to_snapshot.count == 2
109
115
  end
110
116
 
111
117
  end
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.1.1
4
+ version: 0.2.0
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-03-06 00:00:00.000000000 Z
11
+ date: 2021-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -148,6 +148,7 @@ files:
148
148
  - test/dummy_app/app/controllers/application_controller.rb
149
149
  - test/dummy_app/app/models/application_record.rb
150
150
  - test/dummy_app/app/models/comment.rb
151
+ - test/dummy_app/app/models/note.rb
151
152
  - test/dummy_app/app/models/post.rb
152
153
  - test/dummy_app/app/models/volatile_post.rb
153
154
  - test/dummy_app/app/views/layouts/application.html.erb
@@ -211,6 +212,7 @@ test_files:
211
212
  - test/test_helper.rb
212
213
  - test/unit/active_snapshot_test.rb
213
214
  - test/unit/errors_test.rb
215
+ - test/dummy_app/app/models/note.rb
214
216
  - test/dummy_app/app/models/comment.rb
215
217
  - test/dummy_app/app/models/volatile_post.rb
216
218
  - test/dummy_app/app/models/application_record.rb