mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-02 21:57:17 +00:00
Add smoke test for Supplier Totals by Distributor report
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
require "spec_helper"
|
||||
|
||||
RSpec.describe OpenFoodNetwork::OrdersAndFulfillmentsReport::SupplierTotalsByDistributorReport do
|
||||
let!(:distributor) { create(:distributor_enterprise) }
|
||||
|
||||
let!(:order) do
|
||||
create(:completed_order_with_totals, line_items_count: 1, distributor: distributor)
|
||||
end
|
||||
|
||||
let(:current_user) { distributor.owner }
|
||||
let(:permissions) { OpenFoodNetwork::Permissions.new(current_user) }
|
||||
|
||||
let(:report) do
|
||||
report_options = { report_type: described_class::REPORT_TYPE }
|
||||
OpenFoodNetwork::OrdersAndFulfillmentsReport.new(permissions, report_options, true)
|
||||
end
|
||||
|
||||
let(:report_table) do
|
||||
OpenFoodNetwork::OrderGrouper.new(report.rules, report.columns).table(report.table_items)
|
||||
end
|
||||
|
||||
it "generates the report" do
|
||||
expect(report_table.length).to eq(2)
|
||||
end
|
||||
|
||||
it "has a variant row under the distributor" do
|
||||
supplier = order.line_items.first.variant.product.supplier
|
||||
supplier_name_field = report_table.first[0]
|
||||
expect(supplier_name_field).to eq supplier.name
|
||||
|
||||
distributor_name_field = report_table.first[3]
|
||||
expect(distributor_name_field).to eq distributor.name
|
||||
|
||||
total_field = report_table.last[3]
|
||||
expect(total_field).to eq I18n.t("admin.reports.total")
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user