From 28432299b29b215da026f7d0c59cce21999023ca Mon Sep 17 00:00:00 2001 From: Kat Date: Wed, 26 Jan 2022 13:32:47 +0000 Subject: [PATCH] Fix tests Co-authored-by: baarkerlounger --- spec/features/start_page_spec.rb | 1 - spec/features/user_spec.rb | 2 +- spec/requests/auth/passwords_controller_spec.rb | 4 +++- spec/requests/users_controller_spec.rb | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/features/start_page_spec.rb b/spec/features/start_page_spec.rb index 27107bcb6..474a29de0 100644 --- a/spec/features/start_page_spec.rb +++ b/spec/features/start_page_spec.rb @@ -12,7 +12,6 @@ RSpec.describe "Start Page Features" do it "takes you to your logs" do visit("/") - click_link("Start now") expect(page).to have_current_path("/logs") end end diff --git a/spec/features/user_spec.rb b/spec/features/user_spec.rb index 835321c6a..5715e3031 100644 --- a/spec/features/user_spec.rb +++ b/spec/features/user_spec.rb @@ -129,7 +129,7 @@ RSpec.describe "User Features" do fill_in("user[email]", with: user.email) fill_in("user[password]", with: "pAssword1") click_button("Sign in") - expect(page).to have_current_path("/") + expect(page).to have_current_path("/logs") end it "tries to access account page, redirects to log in page" do diff --git a/spec/requests/auth/passwords_controller_spec.rb b/spec/requests/auth/passwords_controller_spec.rb index 61f5cc50a..615455d83 100644 --- a/spec/requests/auth/passwords_controller_spec.rb +++ b/spec/requests/auth/passwords_controller_spec.rb @@ -59,8 +59,10 @@ RSpec.describe Auth::PasswordsController, type: :request do .to(change { user.reload.encrypted_password }) end - it "signs in" do + it "after password change, the user is signed in" do put "/users/password", params: update_password_params + # Devise redirects once after re-sign in with new password and then root redirects as well. + follow_redirect! follow_redirect! expect(page).to have_css("div", class: "govuk-notification-banner__heading", text: message) end diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb index 9d93cb92b..9c537b885 100644 --- a/spec/requests/users_controller_spec.rb +++ b/spec/requests/users_controller_spec.rb @@ -247,6 +247,7 @@ RSpec.describe UsersController, type: :request do it "routes user to the /logs page" do get "/", headers: headers, params: {} expected_link = "href=\"/logs\">#{I18n.t('service_name')}" + follow_redirect! expect(CGI.unescape_html(response.body)).to include(expected_link) end end