active_record-json_associations 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +28 -0
- data/Appraisals +4 -5
- data/gemfiles/{rails_5.0.gemfile → rails_7.0.gemfile} +1 -2
- data/lib/active_record/json_associations/version.rb +1 -1
- data/lib/active_record/json_associations.rb +15 -13
- data/spec/json_associations_spec.rb +8 -0
- metadata +5 -5
- data/.travis.yml +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74ef04233cdf6b923c6be5762d8aa373428bf0ddd74a8fe48f46cbd9b3f16851
|
4
|
+
data.tar.gz: b40d4491c6619ecd3d858864706e3e05e459a3d3f3b20f50eadf0eed416c05db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea1b394dbe6ba8524b50228d9f226af19699171105cd8dda69b7f92f1b1fee6a9dfa06aa85301bfc2403fdb3831972799a38d01a6353c035235e1935fcc57bc2
|
7
|
+
data.tar.gz: e37aec9fff5cfe740cda139ed46c1b7fada912a30a26ebed3945ac6e0a8c7e9356071360278323867f949a666654cf47c9d351b2431c5a2b75fc568273b5439d
|
@@ -0,0 +1,28 @@
|
|
1
|
+
name: CI
|
2
|
+
on: [push, pull_request]
|
3
|
+
jobs:
|
4
|
+
test:
|
5
|
+
strategy:
|
6
|
+
fail-fast: false
|
7
|
+
matrix:
|
8
|
+
gemfile: [ rails_5.1, rails_5.2, rails_6.0, rails_6.1, rails_7.0 ]
|
9
|
+
ruby: [ 2.6, 2.7, '3.0' ]
|
10
|
+
exclude:
|
11
|
+
- gemfile: rails_5.1
|
12
|
+
ruby: 3.0
|
13
|
+
- gemfile: rails_5.2
|
14
|
+
ruby: 3.0
|
15
|
+
- gemfile: rails_7.0
|
16
|
+
ruby: 2.6
|
17
|
+
|
18
|
+
runs-on: ubuntu-latest
|
19
|
+
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
|
20
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v2
|
23
|
+
- uses: ruby/setup-ruby@v1
|
24
|
+
with:
|
25
|
+
ruby-version: ${{ matrix.ruby }}
|
26
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
27
|
+
- run: bundle exec rake
|
28
|
+
|
data/Appraisals
CHANGED
@@ -1,8 +1,3 @@
|
|
1
|
-
appraise "rails-5.0" do
|
2
|
-
gem "rails", "~>5.0.0"
|
3
|
-
gem "sqlite3", "~>1.3.13" # 1.4 seems to break rails 5.0?
|
4
|
-
end
|
5
|
-
|
6
1
|
appraise "rails-5.1" do
|
7
2
|
gem "rails", "~>5.1.0"
|
8
3
|
end
|
@@ -19,3 +14,7 @@ appraise "rails-6.1" do
|
|
19
14
|
gem "rails", "~>6.1.0"
|
20
15
|
end
|
21
16
|
|
17
|
+
appraise "rails-7.0" do
|
18
|
+
gem "rails", "~>7.0.0"
|
19
|
+
end
|
20
|
+
|
@@ -24,20 +24,22 @@ module ActiveRecord
|
|
24
24
|
|
25
25
|
if touch
|
26
26
|
after_commit do
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
scope.
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
attributes.
|
27
|
+
unless no_touching?
|
28
|
+
method = respond_to?(:saved_changes) ? :saved_changes : :previous_changes
|
29
|
+
old_ids, new_ids = send(method)[one_ids.to_s]
|
30
|
+
ids = Array(send(one_ids)) | Array(old_ids) | Array(new_ids)
|
31
|
+
scope = class_name.constantize.where(self.class.primary_key => ids)
|
32
|
+
|
33
|
+
if scope.respond_to?(:touch) # AR 6.0+
|
34
|
+
scope.touch_all
|
35
|
+
elsif self.class.respond_to?(:touch_attributes_with_time) # AR 5.1+
|
36
|
+
scope.update_all self.class.touch_attributes_with_time
|
37
|
+
else # AR 5.0
|
38
|
+
attributes = timestamp_attributes_for_update_in_model.inject({}) do |attributes, key|
|
39
|
+
attributes.merge(key => current_time_from_proper_timezone)
|
40
|
+
end
|
41
|
+
scope.update_all attributes
|
39
42
|
end
|
40
|
-
scope.update_all attributes
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
@@ -185,6 +185,14 @@ describe ActiveRecord::JsonAssociations do
|
|
185
185
|
parent.update!(children: [peter, paul, mary])
|
186
186
|
expect([peter, paul, mary].each(&:reload).map(&:updated_at)).to eq [new_time, new_time, new_time]
|
187
187
|
end
|
188
|
+
|
189
|
+
it "skips touching if in a .no_touching block" do
|
190
|
+
children = [Child.create!, Child.create!]
|
191
|
+
parent = Parent.create!(children: children)
|
192
|
+
children.each { |child| child.update!(updated_at: old_time) }
|
193
|
+
ActiveRecord::Base.no_touching { parent.save! }
|
194
|
+
expect(children.each(&:reload).map(&:updated_at)).to eq [old_time, old_time]
|
195
|
+
end
|
188
196
|
end
|
189
197
|
|
190
198
|
describe "#child_ids" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record-json_associations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micah Geisel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -130,9 +130,9 @@ executables:
|
|
130
130
|
extensions: []
|
131
131
|
extra_rdoc_files: []
|
132
132
|
files:
|
133
|
+
- ".github/workflows/ci.yml"
|
133
134
|
- ".gitignore"
|
134
135
|
- ".rspec"
|
135
|
-
- ".travis.yml"
|
136
136
|
- Appraisals
|
137
137
|
- Gemfile
|
138
138
|
- LICENSE.txt
|
@@ -140,11 +140,11 @@ files:
|
|
140
140
|
- Rakefile
|
141
141
|
- active_record-json_associations.gemspec
|
142
142
|
- bin/setup
|
143
|
-
- gemfiles/rails_5.0.gemfile
|
144
143
|
- gemfiles/rails_5.1.gemfile
|
145
144
|
- gemfiles/rails_5.2.gemfile
|
146
145
|
- gemfiles/rails_6.0.gemfile
|
147
146
|
- gemfiles/rails_6.1.gemfile
|
147
|
+
- gemfiles/rails_7.0.gemfile
|
148
148
|
- lib/active_record/json_associations.rb
|
149
149
|
- lib/active_record/json_associations/version.rb
|
150
150
|
- spec/json_associations_spec.rb
|
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
- !ruby/object:Gem::Version
|
169
169
|
version: '0'
|
170
170
|
requirements: []
|
171
|
-
rubygems_version: 3.
|
171
|
+
rubygems_version: 3.1.6
|
172
172
|
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: Instead of a many-to-many join table, serialize the ids into a JSON array.
|
data/.travis.yml
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.4
|
4
|
-
- 2.5
|
5
|
-
- 2.6
|
6
|
-
- 2.7
|
7
|
-
gemfile:
|
8
|
-
- gemfiles/rails_5.0.gemfile
|
9
|
-
- gemfiles/rails_5.1.gemfile
|
10
|
-
- gemfiles/rails_5.2.gemfile
|
11
|
-
- gemfiles/rails_6.0.gemfile
|
12
|
-
jobs:
|
13
|
-
exclude:
|
14
|
-
- rvm: 2.4
|
15
|
-
gemfile: gemfiles/rails_6.0.gemfile
|
16
|
-
before_install:
|
17
|
-
- gem install bundler -v"~>1.17"
|
18
|
-
|