where_exists 3.2.1 → 3.3.0
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.
- checksums.yaml +4 -4
- data/lib/where_exists/version.rb +1 -1
- data/lib/where_exists.rb +4 -0
- data/test/has_many_test.rb +15 -1
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: db3dd6dd4a33e68a26af47a8b84e8884096bed769f8155c5354614ddb67d3232
|
|
4
|
+
data.tar.gz: 8d79314ae2efc2240ea8ce2200e3562456119e03793d21690f7658234a420e22
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a1a24d0ae23cdfbc98387db469d9becf4bbf8cf3c8771bfce09c9700fb1ac625060bd1e9787ff6816ad697f43c0876631f983fd18fc2903aa59312c489a9ca63
|
|
7
|
+
data.tar.gz: 863923df7462a279eec9009439006e88480fd2809be6df29fa79c2c04b1e5dac5b2ec19e511a2d60d46f297c2e5192c4cc11211cb0674e1141516beb062116b2
|
data/lib/where_exists/version.rb
CHANGED
data/lib/where_exists.rb
CHANGED
data/test/has_many_test.rb
CHANGED
|
@@ -13,7 +13,11 @@ end
|
|
|
13
13
|
|
|
14
14
|
class SimpleEntity < ActiveRecord::Base
|
|
15
15
|
has_many :simple_entity_children, primary_key: :my_id, foreign_key: :parent_id
|
|
16
|
-
has_many :unnamed_children, -> { where name: nil }, primary_key: :my_id, foreign_key: :parent_id, class_name: 'SimpleEntityChild'
|
|
16
|
+
has_many :unnamed_children, -> { where name: nil }, primary_key: :my_id, foreign_key: :parent_id, class_name: 'SimpleEntityChild' do
|
|
17
|
+
def unborn
|
|
18
|
+
where('my_date < ?', Time.now)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
17
21
|
end
|
|
18
22
|
|
|
19
23
|
class SimpleEntityChild < ActiveRecord::Base
|
|
@@ -61,6 +65,16 @@ class HasManyTest < Minitest::Test
|
|
|
61
65
|
assert_equal result.first.id, entity.id
|
|
62
66
|
end
|
|
63
67
|
|
|
68
|
+
def test_with_association_extension_scope
|
|
69
|
+
child = SimpleEntityChild.create!(my_date: Time.now - 1.minute)
|
|
70
|
+
entity = SimpleEntity.create!(simple_entity_children: [child], my_id: 999)
|
|
71
|
+
|
|
72
|
+
result = SimpleEntity.where_exists(:unnamed_children, &:unborn)
|
|
73
|
+
|
|
74
|
+
assert_equal 1, result.length
|
|
75
|
+
assert_equal result.first.id, entity.id
|
|
76
|
+
end
|
|
77
|
+
|
|
64
78
|
def test_with_condition
|
|
65
79
|
child_1 = SimpleEntityChild.create! name: nil
|
|
66
80
|
child_2 = SimpleEntityChild.create! name: 'Luke'
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: where_exists
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Eugene Zolotarev
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activerecord
|
|
@@ -126,7 +125,6 @@ homepage: http://github.com/eugzol/where_exists
|
|
|
126
125
|
licenses:
|
|
127
126
|
- MIT
|
|
128
127
|
metadata: {}
|
|
129
|
-
post_install_message:
|
|
130
128
|
rdoc_options: []
|
|
131
129
|
require_paths:
|
|
132
130
|
- lib
|
|
@@ -141,8 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
141
139
|
- !ruby/object:Gem::Version
|
|
142
140
|
version: '0'
|
|
143
141
|
requirements: []
|
|
144
|
-
rubygems_version:
|
|
145
|
-
signing_key:
|
|
142
|
+
rubygems_version: 4.0.3
|
|
146
143
|
specification_version: 4
|
|
147
144
|
summary: "#where_exists extension of ActiveRecord"
|
|
148
145
|
test_files:
|