Browse Source

update password directing to the right place

pull/110/head
Matthew Phelan 4 years ago
parent
commit
5b53eded94
  1. 7
      app/controllers/users/registrations_controller.rb
  2. 2
      app/views/users/account/index.html.erb
  3. 4
      config/routes.rb
  4. 18
      spec/features/user_spec.rb

7
app/controllers/users/registrations_controller.rb

@ -0,0 +1,7 @@
class Users::RegistrationsController < Devise::RegistrationsController
protected
def after_update_path_for(resource)
users_account_path()
end
end

2
app/views/users/account/index.html.erb

@ -39,7 +39,7 @@
••••••••
</dd>
<dd class="govuk-summary-list__actions">
<%= link_to "Change", edit_user_registration_path %>
<%= link_to "Change", edit_user_registration_path, id: "change-password" %>
</dd>
</div>
<div class="govuk-summary-list__row">

4
config/routes.rb

@ -1,11 +1,11 @@
Rails.application.routes.draw do
devise_for :users, controllers: { passwords: "users/passwords" }, :skip => [:registrations]
devise_for :users, :controllers => { passwords: "users/passwords" }
devise_scope :user do
get "confirmations/reset", to: "users/passwords#reset_confirmation"
end
as :user do
get 'users/edit' => 'devise/registrations#edit', :as => 'edit_user_registration'
put 'users' => 'devise/registrations#update', :as => 'user_registration'
put 'users' => 'users/registrations#update', :as => 'user_registration'
end
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html

18
spec/features/user_spec.rb

@ -52,6 +52,14 @@ RSpec.describe "User Features" do
end
context "Your Account " do
before(:each) do
visit("/case_logs")
fill_in("user_email", with: "test@example.com")
fill_in("user_password", with: "pAssword1")
click_button("Sign in")
end
it "main page is present and accessible" do
visit("/users/account")
expect(page).to have_content("Your account")
@ -75,5 +83,15 @@ RSpec.describe "User Features" do
visit("users/edit")
expect(page).to have_content("Change your password")
end
it "can navigate to change your password page from main account page" do
visit("/users/account")
click_link("change-password")
expect(page).to have_content("Change your password")
fill_in("user_current_password", with: "pAssword1")
fill_in("user_password", with: "Password123!")
click_button("Update")
expect(page).to have_current_path("/users/account")
end
end
end

Loading…
Cancel
Save