mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-05 02:41:33 +00:00
Simplify shipping_method.include? method
This commit is contained in:
@@ -57,8 +57,7 @@ Spree::ShippingMethod.class_eval do
|
||||
# It allows checkout using shipping methods without zones (see issue #3928 for details)
|
||||
# and it allows checkout with addresses outside of the zones of the selected shipping method
|
||||
def include?(address)
|
||||
return false unless address
|
||||
true
|
||||
address.present?
|
||||
end
|
||||
|
||||
def has_distributor?(distributor)
|
||||
|
||||
@@ -92,5 +92,22 @@ module Spree
|
||||
it { expect(shipping_method.delivery?).to be false }
|
||||
end
|
||||
end
|
||||
|
||||
describe "#include?" do
|
||||
let(:shipping_method) { create(:shipping_method) }
|
||||
|
||||
it "does not include a nil address" do
|
||||
expect(shipping_method.include?(nil)).to be false
|
||||
end
|
||||
|
||||
it "includes an address that is not included in the zones of the shipping method" do
|
||||
address = create(:address)
|
||||
zone_mock = instance_double(Spree::Zone)
|
||||
allow(zone_mock).to receive(:include?).with(address).and_return(false)
|
||||
allow(shipping_method).to receive(:zones) { [zone_mock] }
|
||||
|
||||
expect(shipping_method.include?(address)).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user