mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Replaces negative assertion with a positive assertion
Adds test case on white spece Refactors to have tests as shared_examples
This commit is contained in:
@@ -82,20 +82,17 @@ RSpec.describe Reporting::Reports::OrdersAndFulfillment::OrderCycleCustomerTotal
|
||||
# related to https://github.com/openfoodfoundation/openfoodnetwork/issues/13270
|
||||
# not sure how we got DEPRECATION WARNING: Rails 7.0 has deprecated Enumerable.sum
|
||||
# but these scenarios might be related
|
||||
it "handles a nil instead of an actual value" do
|
||||
order.line_items[0].update!(final_weight_volume: nil)
|
||||
expect { report_table }.not_to raise_error(TypeError, "nil can't be coerced into Integer")
|
||||
shared_examples "the report is successfully generated" do |test_case, type|
|
||||
it "if column final_weight_volume is #{test_case}" do
|
||||
order.line_items[0].update!(final_weight_volume: type)
|
||||
expect(report_table.length).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
it "it handles a missing value" do
|
||||
order.line_items[0].update!(final_weight_volume: "")
|
||||
expect { report_table }.not_to raise_error(TypeError, "nil can't be coerced into Integer")
|
||||
end
|
||||
|
||||
it "handles a string input" do
|
||||
order.line_items[0].update!(final_weight_volume: "a string")
|
||||
expect { report_table }.not_to raise_error
|
||||
end
|
||||
it_behaves_like "the report is successfully generated", "nil", nil
|
||||
it_behaves_like "the report is successfully generated", "an empty value", ""
|
||||
it_behaves_like "the report is successfully generated", "a white space", " "
|
||||
it_behaves_like "the report is successfully generated", "a string", "kilograms"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user