Files
openfoodnetwork/spec/models/calculator/per_item_spec.rb
David Cook 918425fd93 Remove customised error message
We're now handling these values on the frontend, so can keep this simple.

fixes up:
 Add numericality validation for *
 Add translation for Active Record error message
2023-04-28 14:02:12 +10:00

17 lines
549 B
Ruby

# frozen_string_literal: true
require 'spec_helper'
describe Calculator::PerItem do
let(:calculator) { Calculator::PerItem.new(preferred_amount: 10) }
let(:shipping_calculable) { double(:calculable) }
let(:line_item) { build_stubbed(:line_item, quantity: 5) }
it { is_expected.to validate_numericality_of(:preferred_amount) }
it "correctly calculates on a single line item object" do
allow(calculator).to receive_messages(calculable: shipping_calculable)
expect(calculator.compute(line_item).to_f).to eq(50) # 5 x 10
end
end