Files
openfoodnetwork/spec/models/spree/price_spec.rb
David Cook 26d6dedd4d Fix FrozenString error
An error was apparent in specs when trying to assign a string as the price. It's not a problem when submitting the form in the browser, I don't know why.

But in any case, it shouldn't be trying to modify a variable passed as a parameter.
2023-08-31 16:41:41 +10:00

39 lines
843 B
Ruby

# frozen_string_literal: true
require 'spec_helper'
module Spree
describe Price do
let(:variant) { create(:variant) }
let(:price) { variant.default_price }
context "when variant is soft-deleted" do
before do
variant.destroy
end
it "can access the variant" do
expect(price.reload.variant).to eq variant
end
end
context "with large values" do
let(:expensive_variant) { build(:variant, price: 10_000_000) }
it "saves without error" do
expect{ expensive_variant.save }.to_not raise_error
expect(expensive_variant.persisted?).to be true
end
end
context "with string" do
it "parses the price" do
variant.price = " 10.25 eur"
variant.save
expect(variant.reload.price).to eq 10.25
end
end
end
end