mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
add specs for weight calculators using lbs
This commit is contained in:
@@ -62,6 +62,8 @@ describe Calculator::Weight do
|
||||
subject.set_preference(:per_unit, 5)
|
||||
subject.set_preference(:unit_from_list, "kg")
|
||||
expect(subject.compute(object_with_order)).to eq(250) # (10 * 1 + 20 * 2) * 5
|
||||
subject.set_preference(:unit_from_list, "lb")
|
||||
expect(subject.compute(object_with_order)).to eq(551.15) # (10 * 1 + 20 * 2) * 5 * 2.2
|
||||
end
|
||||
|
||||
context "when line item final_weight_volume is set" do
|
||||
@@ -214,6 +216,8 @@ describe Calculator::Weight do
|
||||
subject.set_preference(:per_unit, 5)
|
||||
subject.set_preference(:unit_from_list, "kg")
|
||||
expect(subject.calculable.errors.count).to eq(0)
|
||||
subject.set_preference(:unit_from_list, "lb")
|
||||
expect(subject.calculable.errors.count).to eq(0)
|
||||
end
|
||||
|
||||
it "does not allow a preferred_unit of anything but 'kg' or 'lb'" do
|
||||
|
||||
Reference in New Issue
Block a user