Skip to content

Commit

Permalink
fix join sources issue
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmolnar committed Jul 3, 2018
1 parent 85664cb commit dd44511
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ env:
- RAILS=v5.2.0 DB=mysql
- RAILS=v5.2.0 DB=postgres

- RAILS=5-1-stable DB=sqlite3
- RAILS=5-1-stable DB=mysql
- RAILS=5-1-stable DB=postgres

- RAILS=5-0-stable DB=sqlite3
- RAILS=5-0-stable DB=mysql
- RAILS=5-0-stable DB=postgres
Expand Down
17 changes: 5 additions & 12 deletions lib/ransack/adapters/active_record/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,11 @@ def klassify(obj)
# JoinDependency to track table aliases.
#
def join_sources
base, joins =
if ::ActiveRecord::VERSION::MAJOR >= 5
[
Arel::SelectManager.new(@object.table),
@join_dependency.join_constraints(@object.joins_values, @join_type)
]
else
[
Arel::SelectManager.new(@object.engine, @object.table),
@join_dependency.join_constraints(@object.joins_values)
]
end
base, joins = [
Arel::SelectManager.new(@object.table),
@join_dependency.join_constraints(@object.joins_values, @join_type)
]
joins = joins.collect(&:joins).flatten if ::ActiveRecord::VERSION::STRING < Constants::RAILS_5_2
joins.each do |aliased_join|
base.from(aliased_join)
end
Expand Down
2 changes: 0 additions & 2 deletions spec/ransack/adapters/active_record/context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ module ActiveRecord
end

describe '#join_sources' do
# FIXME: fix this test for Rails 4.2 and 5.0.
it 'returns dependent arel join nodes for all searches run against
the context' do
skip "fix this test for Rails 4.2 and > 5"
parents, children = shared_context.join_sources
expect(children.left.name).to eq "children_people"
expect(parents.left.name).to eq "parents_people"
Expand Down

0 comments on commit dd44511

Please sign in to comment.