mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Sort OC report orders by completed_at
This is then consistent with the ordering we use to list orders in /admin, which is more useful. As a result, the test is also more robust.
This commit is contained in:
@@ -65,7 +65,7 @@ module OpenFoodNetwork
|
||||
|
||||
def orders
|
||||
if FeatureToggle.enabled?(:customer_balance, @user)
|
||||
search_result = search.result.order(:id)
|
||||
search_result = search.result.order(:completed_at)
|
||||
orders_with_balance = OutstandingBalance.new(search_result).
|
||||
query.
|
||||
select('spree_orders.*')
|
||||
|
||||
@@ -43,11 +43,10 @@ module OpenFoodNetwork
|
||||
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 }
|
||||
order1 = create(:order, completed_at: 1.day.ago, state: 'complete')
|
||||
order2 = create(:order, completed_at: 2.days.ago, state: 'complete')
|
||||
|
||||
subject.orders
|
||||
expect(subject.orders.pluck(:id)).to eq([order2.id, order1.id])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user