Files
openfoodnetwork/spec/models/spree/price_spec.rb
Matt-Yorkley b9f46d4253 Increase precision on database columns that involve prices
Increases the maximum number of digits (on the left side of the decimal place) that the column can hold, to allow larger values. This change is made in Spree 2.2 and is relevant in cases with either large order values, or certain currencies that have large values as standard. For example, 100 UK Pounds is roughly 4000 Thai Baht. 1 million pounds is unlikely to ever be needed as a value, but 1 million Baht is not so unlikely...
2021-02-07 00:16:32 +00:00

30 lines
656 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
end
end