diff --git a/core/app/models/spree/order.rb b/core/app/models/spree/order.rb index 5a1f890b55f..3a43af88f03 100644 --- a/core/app/models/spree/order.rb +++ b/core/app/models/spree/order.rb @@ -703,11 +703,13 @@ 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) # this is one of 2 places still using User#bill_address - self.bill_address ||= user.bill_address if user.bill_address.try!(:valid?) + self.bill_address ||= bill_address if bill_address.try!(:valid?) # Skip setting ship address if order doesn't have a delivery checkout step # to avoid triggering validations on shipping address - self.ship_address ||= user.ship_address if user.ship_address.try!(:valid?) && checkout_steps.include?("delivery") + self.ship_address ||= ship_address if ship_address.try!(:valid?) && checkout_steps.include?("delivery") end end diff --git a/core/spec/models/spree/order/checkout_spec.rb b/core/spec/models/spree/order/checkout_spec.rb index 7567d9d244e..370e6369027 100644 --- a/core/spec/models/spree/order/checkout_spec.rb +++ b/core/spec/models/spree/order/checkout_spec.rb @@ -147,7 +147,8 @@ def assert_state_changed(order, from, to) it_behaves_like "it references the user's the default address" do let(:address_kind) { :bill } before do - order.user = FactoryGirl.create(:user, bill_address: default_address) + order.user = FactoryGirl.create(:user) + order.user.default_address = default_address order.next! order.reload end