deferring 0.5.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +13 -4
- data/Appraisals +13 -4
- data/LICENSE.txt +1 -1
- data/deferring.gemspec +1 -2
- data/gemfiles/rails_42.gemfile +3 -2
- data/gemfiles/rails_42.gemfile.lock +30 -30
- data/gemfiles/rails_50.gemfile +3 -2
- data/gemfiles/rails_50.gemfile.lock +30 -30
- data/gemfiles/rails_51.gemfile +3 -2
- data/gemfiles/rails_51.gemfile.lock +30 -30
- data/gemfiles/rails_52.gemfile +3 -2
- data/gemfiles/rails_52.gemfile.lock +30 -30
- data/gemfiles/rails_60.gemfile +8 -0
- data/gemfiles/rails_60.gemfile.lock +64 -0
- data/lib/deferring/deferred_association.rb +19 -6
- data/lib/deferring/version.rb +1 -1
- data/spec/lib/deferring_habtm_spec.rb +13 -0
- data/spec/lib/deferring_has_many_spec.rb +57 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/support/matchers/query_matcher.rb +127 -0
- metadata +7 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 14441d2a2db2d40728af34eb27b47b4da1c7961a716be04a10019468298f7cfc
|
4
|
+
data.tar.gz: ddef46c10b1d7fd9f6e44a1f2e5507937c85e42af8424bc8f2d5d96e156de96a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54eedbbfc6be7e60b517e38a94c1b0b248dd55e52ef90036ea17e4148c92ccf0b37ed153732e28601368704a238ec8dc9178cf7eacf3cacf3af180306bf6a0a4
|
7
|
+
data.tar.gz: 4c2f00b244eb1cab289353e5abcb46cdd48e58e656c83dbc5316af84ad826fb20d0974acd57ff5e90e78656044ce0cb800c9f84e87fc4bd8a36065433b0b01b8
|
data/.travis.yml
CHANGED
@@ -1,17 +1,26 @@
|
|
1
1
|
language: ruby
|
2
2
|
|
3
3
|
rvm:
|
4
|
-
- 2.3.
|
5
|
-
- 2.4.
|
6
|
-
- 2.5.
|
7
|
-
-
|
4
|
+
- 2.3.8
|
5
|
+
- 2.4.6
|
6
|
+
- 2.5.5
|
7
|
+
- 2.6.3
|
8
|
+
- 2.7.1
|
8
9
|
|
9
10
|
gemfile:
|
10
11
|
- gemfiles/rails_42.gemfile
|
11
12
|
- gemfiles/rails_50.gemfile
|
12
13
|
- gemfiles/rails_51.gemfile
|
13
14
|
- gemfiles/rails_52.gemfile
|
15
|
+
- gemfiles/rails_60.gemfile
|
14
16
|
|
15
17
|
sudo: false
|
16
18
|
|
17
19
|
script: 'bundle exec rake'
|
20
|
+
|
21
|
+
matrix:
|
22
|
+
exclude:
|
23
|
+
- rvm: 2.3.8
|
24
|
+
gemfile: gemfiles/rails_60.gemfile
|
25
|
+
- rvm: 2.4.6
|
26
|
+
gemfile: gemfiles/rails_60.gemfile
|
data/Appraisals
CHANGED
@@ -1,15 +1,24 @@
|
|
1
1
|
appraise 'rails-42' do
|
2
|
-
gem 'activerecord', '4.2.
|
2
|
+
gem 'activerecord', '4.2.11.3'
|
3
|
+
gem 'sqlite3', '~> 1.3.6'
|
3
4
|
end
|
4
5
|
|
5
6
|
appraise 'rails-50' do
|
6
|
-
gem 'activerecord', '5.0.7'
|
7
|
+
gem 'activerecord', '5.0.7.2'
|
8
|
+
gem 'sqlite3', '~> 1.3.6'
|
7
9
|
end
|
8
10
|
|
9
11
|
appraise 'rails-51' do
|
10
|
-
gem 'activerecord', '5.1.
|
12
|
+
gem 'activerecord', '5.1.7'
|
13
|
+
gem 'sqlite3'
|
11
14
|
end
|
12
15
|
|
13
16
|
appraise 'rails-52' do
|
14
|
-
gem 'activerecord', '5.2.
|
17
|
+
gem 'activerecord', '5.2.4.3'
|
18
|
+
gem 'sqlite3'
|
19
|
+
end
|
20
|
+
|
21
|
+
appraise 'rails-60' do
|
22
|
+
gem 'activerecord', '6.0.3.2'
|
23
|
+
gem 'sqlite3'
|
15
24
|
end
|
data/LICENSE.txt
CHANGED
data/deferring.gemspec
CHANGED
@@ -20,11 +20,10 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
|
-
spec.add_dependency 'activerecord', ['>= 4.2'
|
23
|
+
spec.add_dependency 'activerecord', ['>= 4.2']
|
24
24
|
|
25
25
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
26
26
|
spec.add_development_dependency 'rake'
|
27
27
|
spec.add_development_dependency 'rspec'
|
28
|
-
spec.add_development_dependency 'sqlite3'
|
29
28
|
spec.add_development_dependency 'appraisal'
|
30
29
|
end
|
data/gemfiles/rails_42.gemfile
CHANGED
@@ -1,66 +1,66 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
deferring (0.
|
5
|
-
activerecord (>= 4.2
|
4
|
+
deferring (0.7.0)
|
5
|
+
activerecord (>= 4.2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (4.2.
|
11
|
-
activesupport (= 4.2.
|
10
|
+
activemodel (4.2.11.3)
|
11
|
+
activesupport (= 4.2.11.3)
|
12
12
|
builder (~> 3.1)
|
13
|
-
activerecord (4.2.
|
14
|
-
activemodel (= 4.2.
|
15
|
-
activesupport (= 4.2.
|
13
|
+
activerecord (4.2.11.3)
|
14
|
+
activemodel (= 4.2.11.3)
|
15
|
+
activesupport (= 4.2.11.3)
|
16
16
|
arel (~> 6.0)
|
17
|
-
activesupport (4.2.
|
17
|
+
activesupport (4.2.11.3)
|
18
18
|
i18n (~> 0.7)
|
19
19
|
minitest (~> 5.1)
|
20
20
|
thread_safe (~> 0.3, >= 0.3.4)
|
21
21
|
tzinfo (~> 1.1)
|
22
|
-
appraisal (2.
|
22
|
+
appraisal (2.3.0)
|
23
23
|
bundler
|
24
24
|
rake
|
25
25
|
thor (>= 0.14.0)
|
26
26
|
arel (6.0.4)
|
27
|
-
builder (3.2.
|
28
|
-
concurrent-ruby (1.
|
29
|
-
diff-lcs (1.
|
27
|
+
builder (3.2.4)
|
28
|
+
concurrent-ruby (1.1.6)
|
29
|
+
diff-lcs (1.4.4)
|
30
30
|
i18n (0.9.5)
|
31
31
|
concurrent-ruby (~> 1.0)
|
32
|
-
minitest (5.
|
33
|
-
rake (
|
34
|
-
rspec (3.
|
35
|
-
rspec-core (~> 3.
|
36
|
-
rspec-expectations (~> 3.
|
37
|
-
rspec-mocks (~> 3.
|
38
|
-
rspec-core (3.
|
39
|
-
rspec-support (~> 3.
|
40
|
-
rspec-expectations (3.
|
32
|
+
minitest (5.14.1)
|
33
|
+
rake (13.0.1)
|
34
|
+
rspec (3.9.0)
|
35
|
+
rspec-core (~> 3.9.0)
|
36
|
+
rspec-expectations (~> 3.9.0)
|
37
|
+
rspec-mocks (~> 3.9.0)
|
38
|
+
rspec-core (3.9.2)
|
39
|
+
rspec-support (~> 3.9.3)
|
40
|
+
rspec-expectations (3.9.2)
|
41
41
|
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
-
rspec-support (~> 3.
|
43
|
-
rspec-mocks (3.
|
42
|
+
rspec-support (~> 3.9.0)
|
43
|
+
rspec-mocks (3.9.1)
|
44
44
|
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
-
rspec-support (~> 3.
|
46
|
-
rspec-support (3.
|
45
|
+
rspec-support (~> 3.9.0)
|
46
|
+
rspec-support (3.9.3)
|
47
47
|
sqlite3 (1.3.13)
|
48
|
-
thor (0.
|
48
|
+
thor (1.0.1)
|
49
49
|
thread_safe (0.3.6)
|
50
|
-
tzinfo (1.2.
|
50
|
+
tzinfo (1.2.7)
|
51
51
|
thread_safe (~> 0.1)
|
52
52
|
|
53
53
|
PLATFORMS
|
54
54
|
ruby
|
55
55
|
|
56
56
|
DEPENDENCIES
|
57
|
-
activerecord (= 4.2.
|
57
|
+
activerecord (= 4.2.11.3)
|
58
58
|
appraisal
|
59
59
|
bundler (~> 1.3)
|
60
60
|
deferring!
|
61
61
|
rake
|
62
62
|
rspec
|
63
|
-
sqlite3
|
63
|
+
sqlite3 (~> 1.3.6)
|
64
64
|
|
65
65
|
BUNDLED WITH
|
66
|
-
1.
|
66
|
+
1.17.3
|
data/gemfiles/rails_50.gemfile
CHANGED
@@ -1,64 +1,64 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
deferring (0.
|
5
|
-
activerecord (>= 4.2
|
4
|
+
deferring (0.7.0)
|
5
|
+
activerecord (>= 4.2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (5.0.7)
|
11
|
-
activesupport (= 5.0.7)
|
12
|
-
activerecord (5.0.7)
|
13
|
-
activemodel (= 5.0.7)
|
14
|
-
activesupport (= 5.0.7)
|
10
|
+
activemodel (5.0.7.2)
|
11
|
+
activesupport (= 5.0.7.2)
|
12
|
+
activerecord (5.0.7.2)
|
13
|
+
activemodel (= 5.0.7.2)
|
14
|
+
activesupport (= 5.0.7.2)
|
15
15
|
arel (~> 7.0)
|
16
|
-
activesupport (5.0.7)
|
16
|
+
activesupport (5.0.7.2)
|
17
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
18
|
i18n (>= 0.7, < 2)
|
19
19
|
minitest (~> 5.1)
|
20
20
|
tzinfo (~> 1.1)
|
21
|
-
appraisal (2.
|
21
|
+
appraisal (2.3.0)
|
22
22
|
bundler
|
23
23
|
rake
|
24
24
|
thor (>= 0.14.0)
|
25
25
|
arel (7.1.4)
|
26
|
-
concurrent-ruby (1.
|
27
|
-
diff-lcs (1.
|
28
|
-
i18n (1.
|
26
|
+
concurrent-ruby (1.1.6)
|
27
|
+
diff-lcs (1.4.4)
|
28
|
+
i18n (1.8.3)
|
29
29
|
concurrent-ruby (~> 1.0)
|
30
|
-
minitest (5.
|
31
|
-
rake (
|
32
|
-
rspec (3.
|
33
|
-
rspec-core (~> 3.
|
34
|
-
rspec-expectations (~> 3.
|
35
|
-
rspec-mocks (~> 3.
|
36
|
-
rspec-core (3.
|
37
|
-
rspec-support (~> 3.
|
38
|
-
rspec-expectations (3.
|
30
|
+
minitest (5.14.1)
|
31
|
+
rake (13.0.1)
|
32
|
+
rspec (3.9.0)
|
33
|
+
rspec-core (~> 3.9.0)
|
34
|
+
rspec-expectations (~> 3.9.0)
|
35
|
+
rspec-mocks (~> 3.9.0)
|
36
|
+
rspec-core (3.9.2)
|
37
|
+
rspec-support (~> 3.9.3)
|
38
|
+
rspec-expectations (3.9.2)
|
39
39
|
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
-
rspec-support (~> 3.
|
41
|
-
rspec-mocks (3.
|
40
|
+
rspec-support (~> 3.9.0)
|
41
|
+
rspec-mocks (3.9.1)
|
42
42
|
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
-
rspec-support (~> 3.
|
44
|
-
rspec-support (3.
|
43
|
+
rspec-support (~> 3.9.0)
|
44
|
+
rspec-support (3.9.3)
|
45
45
|
sqlite3 (1.3.13)
|
46
|
-
thor (0.
|
46
|
+
thor (1.0.1)
|
47
47
|
thread_safe (0.3.6)
|
48
|
-
tzinfo (1.2.
|
48
|
+
tzinfo (1.2.7)
|
49
49
|
thread_safe (~> 0.1)
|
50
50
|
|
51
51
|
PLATFORMS
|
52
52
|
ruby
|
53
53
|
|
54
54
|
DEPENDENCIES
|
55
|
-
activerecord (= 5.0.7)
|
55
|
+
activerecord (= 5.0.7.2)
|
56
56
|
appraisal
|
57
57
|
bundler (~> 1.3)
|
58
58
|
deferring!
|
59
59
|
rake
|
60
60
|
rspec
|
61
|
-
sqlite3
|
61
|
+
sqlite3 (~> 1.3.6)
|
62
62
|
|
63
63
|
BUNDLED WITH
|
64
|
-
1.
|
64
|
+
1.17.3
|
data/gemfiles/rails_51.gemfile
CHANGED
@@ -1,58 +1,58 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
deferring (0.
|
5
|
-
activerecord (>= 4.2
|
4
|
+
deferring (0.7.0)
|
5
|
+
activerecord (>= 4.2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (5.1.
|
11
|
-
activesupport (= 5.1.
|
12
|
-
activerecord (5.1.
|
13
|
-
activemodel (= 5.1.
|
14
|
-
activesupport (= 5.1.
|
10
|
+
activemodel (5.1.7)
|
11
|
+
activesupport (= 5.1.7)
|
12
|
+
activerecord (5.1.7)
|
13
|
+
activemodel (= 5.1.7)
|
14
|
+
activesupport (= 5.1.7)
|
15
15
|
arel (~> 8.0)
|
16
|
-
activesupport (5.1.
|
16
|
+
activesupport (5.1.7)
|
17
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
18
|
i18n (>= 0.7, < 2)
|
19
19
|
minitest (~> 5.1)
|
20
20
|
tzinfo (~> 1.1)
|
21
|
-
appraisal (2.
|
21
|
+
appraisal (2.3.0)
|
22
22
|
bundler
|
23
23
|
rake
|
24
24
|
thor (>= 0.14.0)
|
25
25
|
arel (8.0.0)
|
26
|
-
concurrent-ruby (1.
|
27
|
-
diff-lcs (1.
|
28
|
-
i18n (1.
|
26
|
+
concurrent-ruby (1.1.6)
|
27
|
+
diff-lcs (1.4.4)
|
28
|
+
i18n (1.8.3)
|
29
29
|
concurrent-ruby (~> 1.0)
|
30
|
-
minitest (5.
|
31
|
-
rake (
|
32
|
-
rspec (3.
|
33
|
-
rspec-core (~> 3.
|
34
|
-
rspec-expectations (~> 3.
|
35
|
-
rspec-mocks (~> 3.
|
36
|
-
rspec-core (3.
|
37
|
-
rspec-support (~> 3.
|
38
|
-
rspec-expectations (3.
|
30
|
+
minitest (5.14.1)
|
31
|
+
rake (13.0.1)
|
32
|
+
rspec (3.9.0)
|
33
|
+
rspec-core (~> 3.9.0)
|
34
|
+
rspec-expectations (~> 3.9.0)
|
35
|
+
rspec-mocks (~> 3.9.0)
|
36
|
+
rspec-core (3.9.2)
|
37
|
+
rspec-support (~> 3.9.3)
|
38
|
+
rspec-expectations (3.9.2)
|
39
39
|
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
-
rspec-support (~> 3.
|
41
|
-
rspec-mocks (3.
|
40
|
+
rspec-support (~> 3.9.0)
|
41
|
+
rspec-mocks (3.9.1)
|
42
42
|
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
-
rspec-support (~> 3.
|
44
|
-
rspec-support (3.
|
45
|
-
sqlite3 (1.
|
46
|
-
thor (0.
|
43
|
+
rspec-support (~> 3.9.0)
|
44
|
+
rspec-support (3.9.3)
|
45
|
+
sqlite3 (1.4.2)
|
46
|
+
thor (1.0.1)
|
47
47
|
thread_safe (0.3.6)
|
48
|
-
tzinfo (1.2.
|
48
|
+
tzinfo (1.2.7)
|
49
49
|
thread_safe (~> 0.1)
|
50
50
|
|
51
51
|
PLATFORMS
|
52
52
|
ruby
|
53
53
|
|
54
54
|
DEPENDENCIES
|
55
|
-
activerecord (= 5.1.
|
55
|
+
activerecord (= 5.1.7)
|
56
56
|
appraisal
|
57
57
|
bundler (~> 1.3)
|
58
58
|
deferring!
|
@@ -61,4 +61,4 @@ DEPENDENCIES
|
|
61
61
|
sqlite3
|
62
62
|
|
63
63
|
BUNDLED WITH
|
64
|
-
1.
|
64
|
+
1.17.3
|
data/gemfiles/rails_52.gemfile
CHANGED
@@ -1,58 +1,58 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
deferring (0.
|
5
|
-
activerecord (>= 4.2
|
4
|
+
deferring (0.7.0)
|
5
|
+
activerecord (>= 4.2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (5.2.
|
11
|
-
activesupport (= 5.2.
|
12
|
-
activerecord (5.2.
|
13
|
-
activemodel (= 5.2.
|
14
|
-
activesupport (= 5.2.
|
10
|
+
activemodel (5.2.4.3)
|
11
|
+
activesupport (= 5.2.4.3)
|
12
|
+
activerecord (5.2.4.3)
|
13
|
+
activemodel (= 5.2.4.3)
|
14
|
+
activesupport (= 5.2.4.3)
|
15
15
|
arel (>= 9.0)
|
16
|
-
activesupport (5.2.
|
16
|
+
activesupport (5.2.4.3)
|
17
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
18
|
i18n (>= 0.7, < 2)
|
19
19
|
minitest (~> 5.1)
|
20
20
|
tzinfo (~> 1.1)
|
21
|
-
appraisal (2.
|
21
|
+
appraisal (2.3.0)
|
22
22
|
bundler
|
23
23
|
rake
|
24
24
|
thor (>= 0.14.0)
|
25
25
|
arel (9.0.0)
|
26
|
-
concurrent-ruby (1.
|
27
|
-
diff-lcs (1.
|
28
|
-
i18n (1.
|
26
|
+
concurrent-ruby (1.1.6)
|
27
|
+
diff-lcs (1.4.4)
|
28
|
+
i18n (1.8.3)
|
29
29
|
concurrent-ruby (~> 1.0)
|
30
|
-
minitest (5.
|
31
|
-
rake (
|
32
|
-
rspec (3.
|
33
|
-
rspec-core (~> 3.
|
34
|
-
rspec-expectations (~> 3.
|
35
|
-
rspec-mocks (~> 3.
|
36
|
-
rspec-core (3.
|
37
|
-
rspec-support (~> 3.
|
38
|
-
rspec-expectations (3.
|
30
|
+
minitest (5.14.1)
|
31
|
+
rake (13.0.1)
|
32
|
+
rspec (3.9.0)
|
33
|
+
rspec-core (~> 3.9.0)
|
34
|
+
rspec-expectations (~> 3.9.0)
|
35
|
+
rspec-mocks (~> 3.9.0)
|
36
|
+
rspec-core (3.9.2)
|
37
|
+
rspec-support (~> 3.9.3)
|
38
|
+
rspec-expectations (3.9.2)
|
39
39
|
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
-
rspec-support (~> 3.
|
41
|
-
rspec-mocks (3.
|
40
|
+
rspec-support (~> 3.9.0)
|
41
|
+
rspec-mocks (3.9.1)
|
42
42
|
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
-
rspec-support (~> 3.
|
44
|
-
rspec-support (3.
|
45
|
-
sqlite3 (1.
|
46
|
-
thor (0.
|
43
|
+
rspec-support (~> 3.9.0)
|
44
|
+
rspec-support (3.9.3)
|
45
|
+
sqlite3 (1.4.2)
|
46
|
+
thor (1.0.1)
|
47
47
|
thread_safe (0.3.6)
|
48
|
-
tzinfo (1.2.
|
48
|
+
tzinfo (1.2.7)
|
49
49
|
thread_safe (~> 0.1)
|
50
50
|
|
51
51
|
PLATFORMS
|
52
52
|
ruby
|
53
53
|
|
54
54
|
DEPENDENCIES
|
55
|
-
activerecord (= 5.2.
|
55
|
+
activerecord (= 5.2.4.3)
|
56
56
|
appraisal
|
57
57
|
bundler (~> 1.3)
|
58
58
|
deferring!
|
@@ -61,4 +61,4 @@ DEPENDENCIES
|
|
61
61
|
sqlite3
|
62
62
|
|
63
63
|
BUNDLED WITH
|
64
|
-
1.
|
64
|
+
1.17.3
|
@@ -0,0 +1,64 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
deferring (0.7.0)
|
5
|
+
activerecord (>= 4.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (6.0.3.2)
|
11
|
+
activesupport (= 6.0.3.2)
|
12
|
+
activerecord (6.0.3.2)
|
13
|
+
activemodel (= 6.0.3.2)
|
14
|
+
activesupport (= 6.0.3.2)
|
15
|
+
activesupport (6.0.3.2)
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
+
i18n (>= 0.7, < 2)
|
18
|
+
minitest (~> 5.1)
|
19
|
+
tzinfo (~> 1.1)
|
20
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
21
|
+
appraisal (2.3.0)
|
22
|
+
bundler
|
23
|
+
rake
|
24
|
+
thor (>= 0.14.0)
|
25
|
+
concurrent-ruby (1.1.6)
|
26
|
+
diff-lcs (1.4.4)
|
27
|
+
i18n (1.8.3)
|
28
|
+
concurrent-ruby (~> 1.0)
|
29
|
+
minitest (5.14.1)
|
30
|
+
rake (13.0.1)
|
31
|
+
rspec (3.9.0)
|
32
|
+
rspec-core (~> 3.9.0)
|
33
|
+
rspec-expectations (~> 3.9.0)
|
34
|
+
rspec-mocks (~> 3.9.0)
|
35
|
+
rspec-core (3.9.2)
|
36
|
+
rspec-support (~> 3.9.3)
|
37
|
+
rspec-expectations (3.9.2)
|
38
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
+
rspec-support (~> 3.9.0)
|
40
|
+
rspec-mocks (3.9.1)
|
41
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
+
rspec-support (~> 3.9.0)
|
43
|
+
rspec-support (3.9.3)
|
44
|
+
sqlite3 (1.4.2)
|
45
|
+
thor (1.0.1)
|
46
|
+
thread_safe (0.3.6)
|
47
|
+
tzinfo (1.2.7)
|
48
|
+
thread_safe (~> 0.1)
|
49
|
+
zeitwerk (2.3.1)
|
50
|
+
|
51
|
+
PLATFORMS
|
52
|
+
ruby
|
53
|
+
|
54
|
+
DEPENDENCIES
|
55
|
+
activerecord (= 6.0.3.2)
|
56
|
+
appraisal
|
57
|
+
bundler (~> 1.3)
|
58
|
+
deferring!
|
59
|
+
rake
|
60
|
+
rspec
|
61
|
+
sqlite3
|
62
|
+
|
63
|
+
BUNDLED WITH
|
64
|
+
1.17.3
|
@@ -26,14 +26,14 @@ module Deferring
|
|
26
26
|
alias_method :pretty_inspect, :inspect
|
27
27
|
|
28
28
|
delegate :to_s, :to_a, :inspect, :==, # methods undefined by SimpleDelegator
|
29
|
-
:
|
29
|
+
:as_json, to: :objects
|
30
30
|
|
31
31
|
def each(&block)
|
32
32
|
objects.each(&block)
|
33
33
|
end
|
34
34
|
|
35
35
|
# TODO: Add explanation about :first/:last loaded? problem.
|
36
|
-
[:first, :last].each do |method|
|
36
|
+
[:first, :last, :empty?, :size].each do |method|
|
37
37
|
define_method method do
|
38
38
|
unless objects_loaded?
|
39
39
|
original_association.send(method)
|
@@ -46,7 +46,8 @@ module Deferring
|
|
46
46
|
# Delegates methods from Ruby's Array module to the object in the deferred
|
47
47
|
# association.
|
48
48
|
delegate :[]=, :[], :clear, :select!, :reject!, :flatten, :flatten!, :sort!,
|
49
|
-
:keep_if, :delete_if, :sort_by!, :
|
49
|
+
:keep_if, :delete_if, :sort_by!, :length,
|
50
|
+
:each_index,
|
50
51
|
to: :objects
|
51
52
|
|
52
53
|
# Delegates Ruby's Enumerable#find method to the original association.
|
@@ -57,6 +58,18 @@ module Deferring
|
|
57
58
|
original_association.find(*args)
|
58
59
|
end
|
59
60
|
|
61
|
+
# Delegates Ruby's Enumerable#count method to the original association.
|
62
|
+
#
|
63
|
+
# The delegation has to be explicit in this case, because the inclusion of
|
64
|
+
# Enumerable also defines the count-method on DeferredAssociation.
|
65
|
+
def count(*args, &block)
|
66
|
+
if block_given?
|
67
|
+
objects.count(*args, &block)
|
68
|
+
else
|
69
|
+
original_association.count(*args)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
60
73
|
# Delegates Ruby's Enumerable#select method to the original association when
|
61
74
|
# no block has been given. Rails' select-method does not accept a block, so
|
62
75
|
# we know that in that case the select-method has to be called on our
|
@@ -64,9 +77,9 @@ module Deferring
|
|
64
77
|
#
|
65
78
|
# The delegation has to be explicit in this case, because the inclusion of
|
66
79
|
# Enumerable also defines the select-method on DeferredAssociation.
|
67
|
-
def select(value =
|
80
|
+
def select(value = nil, &block)
|
68
81
|
if block_given?
|
69
|
-
objects.select { |*block_args|
|
82
|
+
objects.select { |*block_args| block.call(*block_args) }
|
70
83
|
else
|
71
84
|
original_association.select(value)
|
72
85
|
end
|
@@ -131,7 +144,7 @@ module Deferring
|
|
131
144
|
def destroy(*records)
|
132
145
|
records.flatten.compact.uniq.each do |record|
|
133
146
|
record = record.to_i if record.is_a? String
|
134
|
-
record = objects.detect { |o| o.id == record } if record.is_a?
|
147
|
+
record = objects.detect { |o| o.id == record } if record.is_a? Integer
|
135
148
|
|
136
149
|
run_deferring_callbacks(:unlink, record) {
|
137
150
|
objects.delete(record)
|
data/lib/deferring/version.rb
CHANGED
@@ -377,6 +377,19 @@ RSpec.describe 'deferred has_and_belongs_to_many associations' do
|
|
377
377
|
end
|
378
378
|
end
|
379
379
|
|
380
|
+
describe 'supports methods from Ruby Array' do
|
381
|
+
describe '#each_index' do
|
382
|
+
it 'returns the index of each element in the association' do
|
383
|
+
bob.teams << dba << support
|
384
|
+
bob.save!
|
385
|
+
|
386
|
+
result = []
|
387
|
+
bob.teams.each_index { |i| result << i }
|
388
|
+
expect(result).to eq([0, 1])
|
389
|
+
end
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
380
393
|
describe 'enumerable methods that conflict with ActiveRecord' do
|
381
394
|
describe '#select' do
|
382
395
|
before do
|
@@ -359,6 +359,63 @@ RSpec.describe 'deferred has_many associations' do
|
|
359
359
|
people = Person.all
|
360
360
|
expect(people[1].issues.loaded?).to be_falsey
|
361
361
|
end
|
362
|
+
|
363
|
+
describe 'count' do
|
364
|
+
it 'should not load the association' do
|
365
|
+
person = Person.where(name: 'Bob').first
|
366
|
+
expect(person.issues.count).to eq(2)
|
367
|
+
expect(person.issues.loaded?).to be_falsey
|
368
|
+
end
|
369
|
+
|
370
|
+
it 'should execute a count(*) query, even if the association has already been loaded' do
|
371
|
+
person = Person.where(name: 'Bob').first
|
372
|
+
expect { person.issues.count }.to query(1) { |sql| expect(sql).to include('SELECT COUNT(*) FROM "issues"') }
|
373
|
+
expect { person.issues.to_a }.to query(1)
|
374
|
+
expect(person.issues.loaded?).to be_truthy
|
375
|
+
expect { person.issues.to_a }.to query(0)
|
376
|
+
expect { person.issues.count }.to query(1) { |sql| expect(sql).to include('SELECT COUNT(*) FROM "issues"') }
|
377
|
+
end
|
378
|
+
|
379
|
+
it 'should execute count with a block' do
|
380
|
+
person = Person.where(name: 'Bob').first
|
381
|
+
expect(person.issues.count { |i| i.subject.start_with?('Printer') }).to eq(1)
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
describe 'size' do
|
386
|
+
it 'should not load the association' do
|
387
|
+
person = Person.where(name: 'Bob').first
|
388
|
+
expect(person.issues.size).to eq(2)
|
389
|
+
expect { person.issues.size }.to query(1) { |sql| expect(sql).to include('SELECT COUNT(*) FROM "issues"') }
|
390
|
+
expect(person.issues.loaded?).to be_falsey
|
391
|
+
end
|
392
|
+
|
393
|
+
it 'should not execute query when the association has already been loaded' do
|
394
|
+
person = Person.where(name: 'Bob').first
|
395
|
+
expect { person.issues.size }.to query(1) { |sql| expect(sql).to include('SELECT COUNT(*) FROM "issues"') }
|
396
|
+
expect { person.issues.to_a }.to query(1)
|
397
|
+
expect(person.issues.loaded?).to be_truthy
|
398
|
+
expect { person.issues.to_a }.to query(0)
|
399
|
+
expect { person.issues.size }.to query(0)
|
400
|
+
end
|
401
|
+
end
|
402
|
+
|
403
|
+
describe 'empty?' do
|
404
|
+
it 'should not load the association' do
|
405
|
+
person = Person.where(name: 'Bob').first
|
406
|
+
expect(person.issues.empty?).to be_falsey
|
407
|
+
expect(person.issues.loaded?).to be_falsey
|
408
|
+
end
|
409
|
+
|
410
|
+
it 'should not execute query when the association has already been loaded' do
|
411
|
+
person = Person.where(name: 'Bob').first
|
412
|
+
expect { person.issues.empty? }.to query(1) { |sql| expect(sql).to include('SELECT 1') }
|
413
|
+
expect { person.issues.to_a }.to query(1)
|
414
|
+
expect(person.issues.loaded?).to be_truthy
|
415
|
+
expect { person.issues.to_a }.to query(0)
|
416
|
+
expect { person.issues.empty? }.to query(0)
|
417
|
+
end
|
418
|
+
end
|
362
419
|
end # preloading associations
|
363
420
|
|
364
421
|
describe 'active record api' do
|
data/spec/spec_helper.rb
CHANGED
@@ -5,6 +5,7 @@ require 'support/models/team'
|
|
5
5
|
require 'support/models/issue'
|
6
6
|
require 'support/models/address'
|
7
7
|
require 'support/models/non_validated_issue'
|
8
|
+
require 'support/matchers/query_matcher'
|
8
9
|
|
9
10
|
RSpec.configure do |config|
|
10
11
|
config.disable_monkey_patching!
|
@@ -18,6 +19,8 @@ RSpec.configure do |config|
|
|
18
19
|
# --seed 1234
|
19
20
|
config.order = 'random'
|
20
21
|
|
22
|
+
config.include(Deferring::Matchers)
|
23
|
+
|
21
24
|
# Rollback all the database changes after each spec, poor man's
|
22
25
|
# DatabaseCleaner :-)
|
23
26
|
config.around do |example|
|
@@ -0,0 +1,127 @@
|
|
1
|
+
module Deferring
|
2
|
+
module Matchers
|
3
|
+
|
4
|
+
class ArQuery #:nodoc:
|
5
|
+
cattr_accessor :executed
|
6
|
+
|
7
|
+
@@recording_queries = false
|
8
|
+
def self.recording_queries?
|
9
|
+
@@recording_queries
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(expected, &block)
|
13
|
+
@expected = expected
|
14
|
+
@block = block
|
15
|
+
end
|
16
|
+
|
17
|
+
def matches?(given_proc)
|
18
|
+
@eval_block = false
|
19
|
+
@eval_error = nil
|
20
|
+
ArQuery.executed = []
|
21
|
+
@@recording_queries = true
|
22
|
+
|
23
|
+
given_proc.call
|
24
|
+
|
25
|
+
if @expected.is_a?(Integer)
|
26
|
+
@actual = ArQuery.executed.length
|
27
|
+
@matched = @actual == @expected
|
28
|
+
else
|
29
|
+
@actual = ArQuery.executed.detect { |sql| @expected === sql }
|
30
|
+
@matched = !@actual.nil?
|
31
|
+
end
|
32
|
+
|
33
|
+
eval_block if @block && @matched && !negative_expectation?
|
34
|
+
|
35
|
+
ensure
|
36
|
+
ArQuery.executed = nil
|
37
|
+
@@recording_queries = false
|
38
|
+
return @matched && @eval_error.nil?
|
39
|
+
end
|
40
|
+
|
41
|
+
def eval_block
|
42
|
+
@eval_block = true
|
43
|
+
begin
|
44
|
+
@block[ArQuery.executed]
|
45
|
+
rescue => err
|
46
|
+
@eval_error = err
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def supports_block_expectations?
|
51
|
+
true
|
52
|
+
end
|
53
|
+
|
54
|
+
def failure_message
|
55
|
+
if @eval_error
|
56
|
+
@eval_error.message
|
57
|
+
elsif @expected.is_a?(Integer)
|
58
|
+
"expected #{@expected}, got #{@actual}"
|
59
|
+
else
|
60
|
+
"expected to execute a query with pattern #{@expected.inspect}, but it wasn't"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def failure_message_when_negated
|
65
|
+
if @expected.is_a?(Integer)
|
66
|
+
"did not expect #{@expected}"
|
67
|
+
else
|
68
|
+
"did not expect to execute a query with pattern #{@expected.inspect}, but it was executed"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def description
|
73
|
+
if @expected.is_a?(Integer)
|
74
|
+
@expected == 1 ? 'execute 1 query' : "execute #{@expected} queries"
|
75
|
+
else
|
76
|
+
"execute query with pattern #{@expected.inspect}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def negative_expectation?
|
81
|
+
@negative_expectation ||= !caller.first(3).find { |s| s =~ /should_not/ }.nil?
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def query(expected = 1, &block)
|
86
|
+
ArQuery.new(expected, &block)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# For Rails 6.0
|
92
|
+
module ActiveRecord
|
93
|
+
module ConnectionAdapters
|
94
|
+
module SQLite3
|
95
|
+
module DatabaseStatements
|
96
|
+
[:exec_query, :exec, :execute].each do |method|
|
97
|
+
if respond_to?(method)
|
98
|
+
define_method("#{method}_with_query_record") do |sql, *args|
|
99
|
+
Deferring::Matchers::ArQuery.executed << sql if Deferring::Matchers::ArQuery.recording_queries?
|
100
|
+
send("#{method}_without_query_record", sql, *args)
|
101
|
+
end
|
102
|
+
|
103
|
+
alias_method :"#{method}_without_query_record", method
|
104
|
+
alias_method method, :"#{method}_with_query_record"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# For previous versions of Rails
|
113
|
+
module ActiveRecord
|
114
|
+
module ConnectionAdapters
|
115
|
+
class SQLite3Adapter
|
116
|
+
[:exec_query, :exec, :execute].each do |method|
|
117
|
+
define_method("#{method}_with_query_record") do |sql, *args|
|
118
|
+
Deferring::Matchers::ArQuery.executed << sql if Deferring::Matchers::ArQuery.recording_queries?
|
119
|
+
send("#{method}_without_query_record", sql, *args)
|
120
|
+
end
|
121
|
+
|
122
|
+
alias_method :"#{method}_without_query_record", method
|
123
|
+
alias_method method, :"#{method}_with_query_record"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deferring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robin Roestenburg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -17,9 +17,6 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.2'
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '5.3'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,9 +24,6 @@ dependencies:
|
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '4.2'
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '5.3'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: bundler
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,20 +66,6 @@ dependencies:
|
|
72
66
|
- - ">="
|
73
67
|
- !ruby/object:Gem::Version
|
74
68
|
version: '0'
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: sqlite3
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - ">="
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '0'
|
82
|
-
type: :development
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - ">="
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '0'
|
89
69
|
- !ruby/object:Gem::Dependency
|
90
70
|
name: appraisal
|
91
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -125,6 +105,8 @@ files:
|
|
125
105
|
- gemfiles/rails_51.gemfile.lock
|
126
106
|
- gemfiles/rails_52.gemfile
|
127
107
|
- gemfiles/rails_52.gemfile.lock
|
108
|
+
- gemfiles/rails_60.gemfile
|
109
|
+
- gemfiles/rails_60.gemfile.lock
|
128
110
|
- lib/deferring.rb
|
129
111
|
- lib/deferring/deferred_association.rb
|
130
112
|
- lib/deferring/deferred_callback_listener.rb
|
@@ -134,6 +116,7 @@ files:
|
|
134
116
|
- spec/lib/deferring_nested_attributes_spec.rb
|
135
117
|
- spec/spec_helper.rb
|
136
118
|
- spec/support/active_record.rb
|
119
|
+
- spec/support/matchers/query_matcher.rb
|
137
120
|
- spec/support/models/address.rb
|
138
121
|
- spec/support/models/issue.rb
|
139
122
|
- spec/support/models/non_validated_issue.rb
|
@@ -158,8 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
141
|
- !ruby/object:Gem::Version
|
159
142
|
version: '0'
|
160
143
|
requirements: []
|
161
|
-
|
162
|
-
rubygems_version: 2.5.1
|
144
|
+
rubygems_version: 3.1.4
|
163
145
|
signing_key:
|
164
146
|
specification_version: 4
|
165
147
|
summary: Defer saving ActiveRecord associations until parent is saved
|
@@ -169,9 +151,9 @@ test_files:
|
|
169
151
|
- spec/lib/deferring_nested_attributes_spec.rb
|
170
152
|
- spec/spec_helper.rb
|
171
153
|
- spec/support/active_record.rb
|
154
|
+
- spec/support/matchers/query_matcher.rb
|
172
155
|
- spec/support/models/address.rb
|
173
156
|
- spec/support/models/issue.rb
|
174
157
|
- spec/support/models/non_validated_issue.rb
|
175
158
|
- spec/support/models/person.rb
|
176
159
|
- spec/support/models/team.rb
|
177
|
-
has_rdoc:
|