mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Ensure report rows are always in the same order
I saw the row were returned not respecting any ordering when refreshing the page locally. It made it hard to debug whether or not the customer balance was right. It's less than ideal to use `allow_any_instance_of` but with this legacy and very coupled code, it's the best we can do.
This commit is contained in:
@@ -48,7 +48,7 @@ module OpenFoodNetwork
|
||||
end
|
||||
|
||||
def orders
|
||||
filter search.result
|
||||
filter(search.result.order(:id))
|
||||
end
|
||||
|
||||
def table_items
|
||||
|
||||
@@ -26,6 +26,14 @@ module OpenFoodNetwork
|
||||
expect(subject.orders).to eq([o2])
|
||||
end
|
||||
|
||||
it 'orders them by id' do
|
||||
result = instance_double(ActiveRecord::Relation)
|
||||
allow_any_instance_of(Ransack::Search).to receive(:result).and_return(result)
|
||||
expect(result).to receive(:order).with(:id) { Spree::Order.none }
|
||||
|
||||
subject.orders
|
||||
end
|
||||
|
||||
context "default date range" do
|
||||
it "fetches orders completed in the past month" do
|
||||
o1 = create(:order, completed_at: 1.month.ago - 1.day)
|
||||
|
||||
Reference in New Issue
Block a user