Files
openfoodnetwork/spec/serializers/api/shipping_method_serializer_spec.rb
luisramos0 8a86c0473d Change app config to keep using the same v1 shipping method calculators and not the ones spree v2 introduces, these are copy pasted versions that work with packages
See this commit for more details: 18e5b98f5c (diff-b0846898827183f530c113ad7b83b8ea)

Also:
- remove shipping method restriction on calculators to inherit from Spree::Shipping::ShippingCalculator so that OFN customized calculators keep working
- add shipping method serializer spec to test serialization of all shipping methods configured
2019-01-27 21:03:32 +00:00

22 lines
719 B
Ruby

require 'spec_helper'
describe Api::ShippingMethodSerializer do
let(:shipping_method) { create(:shipping_method) }
it "serializes a test shipping_method" do
serializer = Api::ShippingMethodSerializer.new shipping_method
expect(serializer.to_json).to match(shipping_method.name)
end
it "can serialize all configured shipping method calculators" do
Rails.application.config.spree.calculators.shipping_methods.each do |calculator|
shipping_method.calculator = calculator.new
serializer = Api::ShippingMethodSerializer.new shipping_method
allow(serializer).to receive(:options).and_return(current_order: create(:order))
expect(serializer.price).to eq(0.0)
end
end
end