Skip to content

Commit

Permalink
Failing for calculator with preferences that aren't known
Browse files Browse the repository at this point in the history
If you try accessing a calculator with preferences in the DB, and that
calculator hasn't seen the `serialize` call, Rails will try accessing
the preferences column directly and return a string :(
  • Loading branch information
mamhoff committed Mar 30, 2021
1 parent 1ee9d75 commit 8810f0a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions core/spec/models/spree/stock/estimator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,29 @@ def compute_package(_package)
end
end

context 'with a custom shipping calculator with preference' do
class Spree::Calculator::Shipping::WithUnknownPreferences < Spree::ShippingCalculator
def compute_package(_package)
# no op
end
end

let!(:shipping_methods) do
[
create(
:shipping_method,
calculator: Spree::Calculator::Shipping::WithUnknownPreferences.new(
preferences: { a: "b" }
)
)
]
end

it 'does not raise an error' do
expect { subject.shipping_rates(package) }.not_to raise_error
end
end

context 'with two shipping methods of different cost' do
let!(:shipping_methods) do
[
Expand Down

0 comments on commit 8810f0a

Please sign in to comment.