Skip to content

Commit ba1adca

Browse files
cpfergus1elia
andcommitted
Generate legacy paths with helpers
Co-Authored-By: Elia Schito <elia@schito.me>
1 parent 41dd99a commit ba1adca

4 files changed

Lines changed: 32 additions & 16 deletions

File tree

config/routes.rb

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,39 @@
1616
resources :users, only: [:edit, :update]
1717

1818
devise_scope :spree_user do
19-
# Legacy devise generated routes
20-
get 'user/spree_user/sign_in', to: 'user_sessions#new', as: :new_spree_user_session
21-
post 'user/spree_user/sign_in', to: 'user_sessions#create', as: :spree_user_session
22-
match 'user/spree_user/logout', to: 'user_sessions#destroy', as: :destroy_spree_user_session, via: Devise.sign_out_via
23-
get 'user/spree_user/password/new', to: 'user_passwords#new', as: :new_spree_user_password
24-
get 'user/spree_user/password/edit', to: 'user_passwords#edit', as: :edit_spree_user_password
25-
patch 'user/spree_user/password', to: 'user_passwords#update', as: :spree_user_password
26-
put 'user/spree_user/password', to: 'user_passwords#update'
27-
post 'user/spree_user/password', to: 'user_passwords#create'
28-
get 'user/spree_user/cancel', to: 'user_registrations#cancel', as: :cancel_spree_user_registration
29-
get 'user/spree_user/sign_up', to: 'user_registrations#new', as: :new_spree_user_registration
30-
get 'user/spree_user/edit', to: 'user_registrations#edit', as: :edit_spree_user_registration
31-
patch 'user/spree_user', to: 'user_registrations#update', as: :spree_user_registration
19+
# Legacy devise generated paths
20+
# These are deprecated but we still want to support the incoming routes,
21+
# in order to give existing stores an upgrade path.
22+
get 'user/spree_user/sign_in', to: 'user_sessions#new', as: nil
23+
post 'user/spree_user/sign_in', to: 'user_sessions#create', as: nil
24+
match 'user/spree_user/logout', to: 'user_sessions#destroy', via: Devise.sign_out_via, as: nil
25+
get 'user/spree_user/password/new', to: 'user_passwords#new', as: nil
26+
get 'user/spree_user/password/edit', to: 'user_passwords#edit', as: nil
27+
patch 'user/spree_user/password', to: 'user_passwords#update', as: nil
28+
put 'user/spree_user/password', to: 'user_passwords#update', as: nil
29+
post 'user/spree_user/password', to: 'user_passwords#create', as: nil
30+
get 'user/spree_user/cancel', to: 'user_registrations#cancel', as: nil
31+
get 'user/spree_user/sign_up', to: 'user_registrations#new', as: nil
32+
get 'user/spree_user/edit', to: 'user_registrations#edit', as: nil
33+
patch 'user/spree_user', to: 'user_registrations#update', as: nil
3234
put 'user/spree_user', to: 'user_registrations#update', as: nil
3335
delete 'user/spree_user', to: 'user_registrations#destroy', as: nil
3436
post 'user/spree_user', to: 'user_registrations#create', as: nil
3537

38+
# Legacy devise generated helpers
39+
# These helpers are deprecated but we still want to support them
40+
# in order to give existing stores an upgrade path.
41+
get '/login', to: 'user_sessions#new', as: :new_spree_user_session
42+
post '/login', to: 'user_sessions#create', as: :spree_user_session
43+
match '/logout', to: 'user_sessions#destroy', as: :destroy_spree_user_session, via: Devise.sign_out_via
44+
get '/password/recover', to: 'user_passwords#new', as: :new_spree_user_password
45+
get '/password/change', to: 'user_passwords#edit', as: :edit_spree_user_password
46+
patch '/password/change', to: 'user_passwords#update', as: :spree_user_password
47+
get '/spree_user/cancel', to: 'user_registrations#cancel', as: :cancel_spree_user_registration
48+
get '/signup', to: 'user_registrations#new', as: :new_spree_user_registration
49+
get '/spree_user/edit', to: 'user_registrations#edit', as: :edit_spree_user_registration
50+
patch '/spree_user', to: 'user_registrations#update', as: :spree_user_registration
51+
3652
# Custom devise routes
3753
get '/login', to: 'user_sessions#new', as: :login
3854
post '/login', to: 'user_sessions#create', as: :create_new_session

spec/controllers/spree/user_passwords_controller_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
it 'redirects to the new session path' do
1111
get :edit
1212
expect(response).to redirect_to(
13-
'http://test.host/user/spree_user/sign_in'
13+
'http://test.host/login'
1414
)
1515
end
1616

spec/features/checkout_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
# Need to do this now because the token stored in the DB is the encrypted version
112112
# The 'plain-text' version is sent in the email and there's one way to get that!
113113
reset_password_email = ActionMailer::Base.deliveries.first
114-
token_url_regex = /\/user\/spree_user\/password\/edit\?reset_password_token=(.*)$/
114+
token_url_regex = /\/password\/change\?reset_password_token=(.*)$/
115115
token = token_url_regex.match(reset_password_email.body.to_s)[1]
116116

117117
visit spree.edit_spree_user_password_path(reset_password_token: token)

spec/mailers/user_mailer_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
context 'body includes' do
3333
it 'password reset url' do
34-
expect(@message.body.raw_source).to include "http://#{store.url}/user/spree_user/password/edit"
34+
expect(@message.body.raw_source).to include "http://#{store.url}/password/change"
3535
end
3636
end
3737
end

0 commit comments

Comments
 (0)