File tree Expand file tree Collapse file tree
lib/controllers/frontend/spree Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,14 +28,17 @@ def create
2828 def update
2929 if @user . update ( user_params )
3030 spree_current_user . reload
31+ redirect_url = spree . account_url
3132
3233 if params [ :user ] [ :password ] . present?
3334 # this logic needed b/c devise wants to log us out after password changes
34- unless Spree ::Auth ::Config [ :signout_after_password_change ]
35+ if Spree ::Auth ::Config [ :signout_after_password_change ]
36+ redirect_url = spree . login_url
37+ else
3538 bypass_sign_in ( @user )
3639 end
3740 end
38- redirect_to spree . account_url , notice : I18n . t ( 'spree.account_updated' )
41+ redirect_to redirect_url , notice : I18n . t ( 'spree.account_updated' )
3942 else
4043 render :edit
4144 end
Original file line number Diff line number Diff line change 4646 expect ( subject . spree_current_user . email ) . to eq user . email
4747 end
4848 end
49+
50+ context 'when updating password' do
51+ before do
52+ stub_spree_preferences ( Spree ::Auth ::Config , signout_after_password_change : signout_after_change )
53+ put :update , params : { user : { password : 'foobar123' , password_confirmation : 'foobar123' } }
54+ end
55+
56+ context 'when signout after password change is enabled' do
57+ let ( :signout_after_change ) { true }
58+
59+ it 'redirects to login url' do
60+ expect ( response ) . to redirect_to spree . login_url ( only_path : true )
61+ end
62+ end
63+
64+ context 'when signout after password change is disabled' do
65+ let ( :signout_after_change ) { false }
66+
67+ it 'redirects to account url' do
68+ expect ( response ) . to redirect_to spree . account_url ( only_path : true )
69+ end
70+ end
71+ end
4972 end
5073
5174 it 'does not update roles' do
You can’t perform that action at this time.
0 commit comments