From dbd3eab06dd22315853c778e7ad1cb2810000629 Mon Sep 17 00:00:00 2001 From: Greg Molnar Date: Sun, 14 Apr 2019 17:17:56 +0200 Subject: [PATCH] fix join dependency spec --- spec/ransack/join_dependency_spec.rb | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/spec/ransack/join_dependency_spec.rb b/spec/ransack/join_dependency_spec.rb index 4c73871..3527859 100644 --- a/spec/ransack/join_dependency_spec.rb +++ b/spec/ransack/join_dependency_spec.rb @@ -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)