Skip to content

Commit

Permalink
Reproduce the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
pablobm committed Feb 13, 2020
1 parent 650a2d6 commit 7847fde
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions spec/lib/administrate/order_spec.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 7847fde

Please sign in to comment.