fix join dependency spec

This commit is contained in:
Greg Molnar 2019-04-14 17:17:56 +02:00
parent 99cbc190ad
commit dbd3eab06d
1 changed files with 17 additions and 6 deletions

View File

@ -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
@ -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
@ -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)