mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Specify order addresses in some OrderSyncer specs
This is to check that we are using the correct address data in assertions. This also clarifies the scenario for one of the specs.
This commit is contained in:
@@ -128,11 +128,17 @@ describe OrderSyncer do
|
||||
describe "changing the billing address" do
|
||||
let!(:distributor_address) { create(:address, address1: "Distributor Address") }
|
||||
let!(:distributor) { create(:distributor_enterprise, address: distributor_address) }
|
||||
let!(:original_ship_address) { create(:address) }
|
||||
let!(:original_bill_address) do
|
||||
create(:address, firstname: "Walter", lastname: "Wolf", address1: "White")
|
||||
end
|
||||
let!(:original_ship_address) do
|
||||
create(:address, firstname: "Melanie", lastname: "Miller", address1: "Magenta")
|
||||
end
|
||||
|
||||
let(:subscription) do
|
||||
create(:subscription, shop: distributor, ship_address: original_ship_address,
|
||||
with_items: true, with_proxy_orders: true)
|
||||
create(:subscription, shop: distributor, bill_address: original_bill_address,
|
||||
ship_address: original_ship_address, with_items: true,
|
||||
with_proxy_orders: true)
|
||||
end
|
||||
|
||||
let(:shipping_method) { subscription.shipping_method }
|
||||
@@ -156,7 +162,7 @@ describe OrderSyncer do
|
||||
expect(order.bill_address.address1).to eq "123 abc st"
|
||||
expect(order.bill_address.phone).to eq "1123581321"
|
||||
expect(order.ship_address.firstname).to eq "Bill"
|
||||
expect(order.ship_address.lastname).to eq ship_address_attrs["lastname"]
|
||||
expect(order.ship_address.lastname).to eq bill_address_attrs["lastname"]
|
||||
expect(order.ship_address.address1).to eq distributor_address.address1
|
||||
expect(order.ship_address.phone).to eq "1123581321"
|
||||
end
|
||||
@@ -174,7 +180,7 @@ describe OrderSyncer do
|
||||
expect(order.bill_address.address1).to eq bill_address_attrs["address1"]
|
||||
expect(order.bill_address.phone).to eq bill_address_attrs["phone"]
|
||||
expect(order.ship_address.firstname).to eq "Jane"
|
||||
expect(order.ship_address.lastname).to eq ship_address_attrs["lastname"]
|
||||
expect(order.ship_address.lastname).to eq bill_address_attrs["lastname"]
|
||||
expect(order.ship_address.address1).to eq distributor_address.address1
|
||||
expect(order.ship_address.phone).to eq ship_address_attrs["phone"]
|
||||
end
|
||||
@@ -225,11 +231,17 @@ describe OrderSyncer do
|
||||
describe "changing the ship address" do
|
||||
let!(:distributor_address) { create(:address, address1: "Distributor Address") }
|
||||
let!(:distributor) { create(:distributor_enterprise, address: distributor_address) }
|
||||
let!(:original_ship_address) { create(:address) }
|
||||
let!(:original_bill_address) do
|
||||
create(:address, firstname: "Walter", lastname: "Wolf", address1: "White")
|
||||
end
|
||||
let!(:original_ship_address) do
|
||||
create(:address, firstname: "Melanie", lastname: "Miller", address1: "Magenta")
|
||||
end
|
||||
|
||||
let(:subscription) do
|
||||
create(:subscription, shop: distributor, ship_address: original_ship_address,
|
||||
with_items: true, with_proxy_orders: true)
|
||||
create(:subscription, shop: distributor, bill_address: original_bill_address,
|
||||
ship_address: original_ship_address, with_items: true,
|
||||
with_proxy_orders: true)
|
||||
end
|
||||
|
||||
let(:shipping_method) { subscription.shipping_method }
|
||||
@@ -247,8 +259,8 @@ describe OrderSyncer do
|
||||
expect(syncer.sync!).to be true
|
||||
expect(syncer.order_update_issues.keys).to_not include order.id
|
||||
order.reload;
|
||||
expect(order.ship_address.firstname).to eq ship_address_attrs["firstname"]
|
||||
expect(order.ship_address.lastname).to eq ship_address_attrs["lastname"]
|
||||
expect(order.ship_address.firstname).to eq bill_address_attrs["firstname"]
|
||||
expect(order.ship_address.lastname).to eq bill_address_attrs["lastname"]
|
||||
expect(order.ship_address.address1).to eq distributor_address.address1
|
||||
expect(order.ship_address.phone).to eq ship_address_attrs["phone"]
|
||||
end
|
||||
@@ -258,8 +270,12 @@ describe OrderSyncer do
|
||||
|
||||
before { params.merge!(shipping_method_id: new_shipping_method.id) }
|
||||
|
||||
context "when the original ship address is the same as the distributor address" do
|
||||
let!(:original_ship_address) { create(:address, address1: distributor_address.address1) }
|
||||
context "when the original ship address is the bill contact using distributor address" do
|
||||
let!(:original_ship_address) do
|
||||
create(:address, firstname: original_bill_address.firstname,
|
||||
lastname: original_bill_address.lastname,
|
||||
address1: distributor_address.address1)
|
||||
end
|
||||
|
||||
it "updates ship_address attrs" do
|
||||
subscription.assign_attributes(params)
|
||||
|
||||
Reference in New Issue
Block a user