From 91b54fcefa2bfe893f5e12435e7e79363e6e21ca Mon Sep 17 00:00:00 2001 From: Lorenzo Fermi Date: Sun, 29 Mar 2020 14:26:57 +0200 Subject: [PATCH] Remove calls to deprecated methods (in both code and specs) --- core/app/models/spree/order.rb | 4 ++-- .../spec/models/spree/concerns/user_address_book_spec.rb | 9 +-------- core/spec/models/spree/order/checkout_spec.rb | 4 ++-- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/core/app/models/spree/order.rb b/core/app/models/spree/order.rb index 4a0f28ed48c..57454b32502 100644 --- a/core/app/models/spree/order.rb +++ b/core/app/models/spree/order.rb @@ -744,8 +744,8 @@ def ship_address_attributes=(attributes) # @note This doesn't persist the change bill_address or ship_address def assign_default_user_addresses if user - bill_address = (user.bill_address || user.default_address) - ship_address = (user.ship_address || user.default_address) + bill_address = user.bill_address + ship_address = user.ship_address # this is one of 2 places still using User#bill_address self.bill_address ||= bill_address if bill_address.try!(:valid?) # Skip setting ship address if order doesn't have a delivery checkout step diff --git a/core/spec/models/spree/concerns/user_address_book_spec.rb b/core/spec/models/spree/concerns/user_address_book_spec.rb index f3072da8931..c8779e09ff2 100644 --- a/core/spec/models/spree/concerns/user_address_book_spec.rb +++ b/core/spec/models/spree/concerns/user_address_book_spec.rb @@ -79,7 +79,6 @@ module Spree user.save_in_address_book(address.attributes, true) expect(user.addresses.count).to eq 3 expect(user.ship_address.address1).to eq address.address1 - expect(user.default_address.address1).to eq address.address1 end end end @@ -243,7 +242,6 @@ module Spree it "sets the passed address as default shipping address" do subject expect(user.ship_address).to eq address - expect(user.default_address).to eq address end end @@ -460,11 +458,6 @@ module Spree it "stores the ship_address" do expect(subject.ship_address).to eq ship_address end - - it "is also available as default_address" do - expect(subject.ship_address).to eq ship_address - expect(subject.default_address).to eq ship_address - end end describe "#ship_address=" do @@ -565,7 +558,7 @@ module Spree allow(Spree::Address).to receive(:immutable_merge).and_return address end - it do + it "updates ship_address with its present attributes merged with the passed ones" do expect(Spree::Address).to receive(:immutable_merge).with(user.ship_address, attributes) expect(user).to receive(:ship_address=).with address diff --git a/core/spec/models/spree/order/checkout_spec.rb b/core/spec/models/spree/order/checkout_spec.rb index ceb3b20a663..41d85b96d67 100644 --- a/core/spec/models/spree/order/checkout_spec.rb +++ b/core/spec/models/spree/order/checkout_spec.rb @@ -140,7 +140,7 @@ def assert_state_changed(order, from, to) let(:address_kind) { :ship } before do order.user = FactoryBot.create(:user) - order.user.default_address = default_address + order.user.ship_address = default_address order.next! order.reload end @@ -150,7 +150,7 @@ def assert_state_changed(order, from, to) let(:address_kind) { :bill } before do order.user = FactoryBot.create(:user) - order.user.default_address = default_address + order.user.bill_address = default_address order.next! order.reload end