From 5b53eded94ba32de6cb80427f498bebe8e680382 Mon Sep 17 00:00:00 2001 From: Matthew Phelan Date: Mon, 22 Nov 2021 12:26:17 +0000 Subject: [PATCH] update password directing to the right place --- .../users/registrations_controller.rb | 7 +++++++ app/views/users/account/index.html.erb | 2 +- config/routes.rb | 4 ++-- spec/features/user_spec.rb | 18 ++++++++++++++++++ 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 app/controllers/users/registrations_controller.rb diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb new file mode 100644 index 000000000..8088d36dc --- /dev/null +++ b/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 + \ No newline at end of file diff --git a/app/views/users/account/index.html.erb b/app/views/users/account/index.html.erb index 8a84497a3..37a4560de 100644 --- a/app/views/users/account/index.html.erb +++ b/app/views/users/account/index.html.erb @@ -39,7 +39,7 @@ ••••••••
- <%= link_to "Change", edit_user_registration_path %> + <%= link_to "Change", edit_user_registration_path, id: "change-password" %>
diff --git a/config/routes.rb b/config/routes.rb index 4fc1470b8..b1d3c55c0 100644 --- a/config/routes.rb +++ b/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 diff --git a/spec/features/user_spec.rb b/spec/features/user_spec.rb index 857c6e48d..44c7e47e7 100644 --- a/spec/features/user_spec.rb +++ b/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