List each order only once in report

This commit is contained in:
Maikel Linke
2020-05-14 14:07:16 +10:00
parent 19f7f04816
commit 2d95e9ebc0
2 changed files with 4 additions and 4 deletions

View File

@@ -34,7 +34,9 @@ module OpenFoodNetwork
end
def search
@permissions.visible_orders.complete.not_state(:canceled).search(@params[:q])
@permissions.visible_orders.select("DISTINCT spree_orders.*").
complete.not_state(:canceled).
search(@params[:q])
end
def table

View File

@@ -73,14 +73,12 @@ module OpenFoodNetwork
end
it "prints one row per line item" do
pending "Each line item is shown multiple times when there is more than one item in the order"
create(:line_item_with_shipment, order: order)
subject = OrderAndDistributorReport.new(create(:admin_user), {}, true)
table = subject.table
expect(table.size).to eq 2 # currently 4
expect(table.size).to eq 2
end
end
end