where_exists 0.9 → 0.9.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c0011ebbfa83fbd7bec538f131b3cbd1840a461
4
- data.tar.gz: be15ecc2aa3b857edeb0c7f577b3d2a23b73cb3f
3
+ metadata.gz: 9e6f042ea66ced8e828fa202fe84705b55846641
4
+ data.tar.gz: b28d7eaf45be811108a93108355ce05c2ca5f2d4
5
5
  SHA512:
6
- metadata.gz: f287f7afb2c78828f04306abd07f2329af3184f3e618cf701e385aa2ae42ba1aa42a4223201b874d89fba1cf1180b968e3e82f24c80fd3bef6fd121024cfa330
7
- data.tar.gz: c1d91193439fd382019cd7952698b3db625ef8ac1c96b836d7ab7382f417eb53951713882b958f496383f488b807069a1d1e9f81a017cd24165d4ede5b9a9716
6
+ metadata.gz: bc5ccf9d5987400e2533b60bbef83b5643a23f7e2780b1e8db83546f2838eb239fb43bb3e1f9ae7e4738255d390a21f25ea989c1cf1afa88fc72b0483ae25baa
7
+ data.tar.gz: 96255b728f3de38c8d48298eac8a6eb53b78550eb985cc37ccb3f9d93b31ea68f86171a89708b9f6a59260bd2bf22b9e0c43f29969c20e3ccf91114f4b190483
data/lib/where_exists.rb CHANGED
@@ -71,7 +71,7 @@ module WhereExists
71
71
  through = association.options[:through].present?
72
72
 
73
73
  if through
74
- original_association_name = association.name
74
+ next_association = association.source_reflection
75
75
  association = association.through_reflection
76
76
  end
77
77
 
@@ -89,10 +89,7 @@ module WhereExists
89
89
  end
90
90
 
91
91
  if through
92
- unless associated_model.reflect_on_association(original_association_name)
93
- original_association_name = original_association_name.to_s.singularize.to_sym
94
- end
95
- result = result.where_exists(original_association_name, where_parameters)
92
+ result = result.where_exists(next_association.name, where_parameters)
96
93
  else
97
94
  result = result.where(where_parameters)
98
95
  end
@@ -1,3 +1,3 @@
1
1
  module WhereExists
2
- VERSION = "0.9"
2
+ VERSION = "0.9.1"
3
3
  end
data/test/db/test.db CHANGED
Binary file
@@ -22,7 +22,7 @@ end
22
22
  class Project < ActiveRecord::Base
23
23
  has_many :tasks
24
24
  has_many :invoices, :through => :tasks
25
- has_many :line_items, :through => :tasks
25
+ has_many :project_line_items, :through => :tasks, :source => :line_items
26
26
  end
27
27
 
28
28
  class Task < ActiveRecord::Base
@@ -59,12 +59,12 @@ class HasManyThroughTest < Minitest::Unit::TestCase
59
59
  line_item = LineItem.create!(name: 'relevant', task: task)
60
60
  irrelevant_line_item = LineItem.create!(name: 'irrelevant', task: irrelevant_task)
61
61
 
62
- result = Project.where_exists(:line_items, name: 'relevant')
62
+ result = Project.where_exists(:project_line_items, name: 'relevant')
63
63
 
64
64
  assert_equal 1, result.length
65
65
  assert_equal project.id, result.first.id
66
66
 
67
- result = Project.where_not_exists(:line_items, name: 'relevant')
67
+ result = Project.where_not_exists(:project_line_items, name: 'relevant')
68
68
  assert_equal 1, result.length
69
69
  assert_equal irrelevant_project.id, result.first.id
70
70
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: where_exists
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.9'
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugene Zolotarev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-30 00:00:00.000000000 Z
11
+ date: 2015-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails