-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove user address reference when removing address from the address #3482
Remove user address reference when removing address from the address #3482
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SamuelMartini thank you for this fix! I left a minor note on tests, hope it makes sense
@@ -242,6 +242,35 @@ module Spree | |||
it "returns false if the addresses is not there" do | |||
expect(user.remove_from_address_book(0)).to be false | |||
end | |||
|
|||
context 'when user has previous order addresses' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that besides all these cases when the attributes match and so they are then changed to nil
, it would be nice to have at least one test for the other scenarios when they don't match and they are not changed... what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @spaghetticode, thank you for the comment!
Added example when the address does not match any user addresses: https://github.com/solidusio/solidus/pull/3482/files#diff-e930e6c49d94b00d1756dfaf242e4d68R252-R264
…book The address book should provide the user the ability to manage all his addresses. `ship_address_id` and `bill_address_id` are persisted on the `Spree::User` record after transitioning from `address`: `Spree::User#persist_order_address`. This address fields are used to assign user default addresses to the order before transitioning to `address`: `Spree::Order#assign_default_user_addresses`. When a user empties the address book he does not expect the removed address being shown again during the checkout or elsewhere. This commit removes the address reference from the user record when an address is removed from the address book.
2da3a9c
to
63d02a9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SamuelMartini thank you 👍
Description
The address book should provide the user the ability to manage all his addresses.
ship_address_id
andbill_address_id
are persisted on theSpree::User
record after transitioning fromaddress
:Spree::User#persist_order_address
.solidus/core/app/models/concerns/spree/user_address_book.rb
Lines 70 to 77 in 18f6ebc
These address fields are used to assign user default addresses to the order before transitioning to
address
:Spree::Order#assign_default_user_addresses
.solidus/core/app/models/spree/order.rb
Lines 716 to 726 in d0d1e3d
Currently, when a user empties his address book the
user
record still has theship_address_id
andbill_address_id
references.In the
address
checkout step because ofassign_default_user_addresses
the order addresses are filled with addresses linked on the user record.As a user I expect that when I empty my address book no address will be shown during my next checkout.
As a developer I expect to use the address book to provide the user full management capability on his addresses.
This commit removes the address reference from the user record when an address is removed from the address book.
Checklist: