Skip to content

Commit

Permalink
fix join dependency spec
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmolnar committed Apr 14, 2019
1 parent 99cbc19 commit dbd3eab
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions spec/ransack/join_dependency_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ module Polyamorous

specify { expect(subject.send(:join_root).drop(1).size)
.to eq(2) }
specify { expect(subject.send(:join_root).drop(1).map(&:join_type))
.to be_all { Polyamorous::InnerJoin } }
specify { expect(subject.send(:join_root).drop(1).map(&:join_type).uniq)
.to eq [Polyamorous::InnerJoin] }
end

context 'with has_many :through association' do
Expand Down Expand Up @@ -38,8 +38,8 @@ module Polyamorous
.to eq 2 }
specify { expect(subject.send(:join_root).drop(1).map(&:join_type))
.to eq [Polyamorous::OuterJoin, Polyamorous::OuterJoin] }
specify { expect(subject.send(:join_root).drop(1).map(&:join_type))
.to be_all { Polyamorous::OuterJoin } }
specify { expect(subject.send(:join_root).drop(1).map(&:join_type).uniq)
.to eq [Polyamorous::OuterJoin] }
end

context 'with polymorphic belongs_to join' do
Expand All @@ -59,8 +59,19 @@ module Polyamorous

specify { expect(subject.send(:join_root).drop(1).size)
.to eq 2 }
specify { expect(subject.send(:join_root).drop(1).map(&:join_type))
.to be_all { Polyamorous::InnerJoin } }
specify { expect(subject.send(:join_root).drop(1).map(&:join_type).uniq)
.to eq [Polyamorous::InnerJoin] }
specify { expect(subject.send(:join_root).drop(1).first.table_name)
.to eq 'people' }
specify { expect(subject.send(:join_root).drop(1)[1].table_name)
.to eq 'comments' }
end

context 'with polymorphic belongs_to join and nested join' do
subject { new_join_dependency Note,
new_join(:notable, :outer, Person) => :comments }
specify { expect(subject.send(:join_root).drop(1).size).to eq 2 }
specify { expect(subject.send(:join_root).drop(1).map(&:join_type)).to eq [Polyamorous::OuterJoin, Polyamorous::InnerJoin] }
specify { expect(subject.send(:join_root).drop(1).first.table_name)
.to eq 'people' }
specify { expect(subject.send(:join_root).drop(1)[1].table_name)
Expand Down

0 comments on commit dbd3eab

Please sign in to comment.