From 7847fde9e08b0a864a70df6c2fd2b7bca9fe0cca Mon Sep 17 00:00:00 2001 From: Pablo Brasero Date: Thu, 13 Feb 2020 22:26:00 +0000 Subject: [PATCH] Reproduce the issue --- spec/lib/administrate/order_spec.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/spec/lib/administrate/order_spec.rb b/spec/lib/administrate/order_spec.rb index 33bc27aeff..eca7eda98d 100644 --- a/spec/lib/administrate/order_spec.rb +++ b/spec/lib/administrate/order_spec.rb @@ -73,12 +73,12 @@ context "when relation has belongs_to association" do it "orders by id" do order = Administrate::Order.new(:name) - relation = relation_with_association(:belongs_to) + relation = relation_with_association(:belongs_to, foreign_key: "some_foreign_key") allow(relation).to receive(:reorder).and_return(relation) ordered = order.apply(relation) - expect(relation).to have_received(:reorder).with("name_id asc") + expect(relation).to have_received(:reorder).with("some_foreign_key asc") expect(ordered).to eq(relation) end end @@ -176,9 +176,15 @@ def relation_with_column(column) ) end - def relation_with_association(association) + def relation_with_association(association, foreign_key: "#{association}_id") double( - klass: double(reflect_on_association: double(macro: association)), + klass: double( + reflect_on_association: double( + "#{association}_reflection", + macro: association, + foreign_key: foreign_key, + ), + ), ) end end