Browse Source

Redirect logged in users to /logs from the index page (#243)

* redirect logged in users to /logs from the index page

* Fix tests

Co-authored-by: baarkerlounger  <baarkerlounger@users.noreply.github.com>

Co-authored-by: baarkerlounger  <baarkerlounger@users.noreply.github.com>
pull/248/head
kosiakkatrina 3 years ago committed by GitHub
parent
commit
e057c396cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/controllers/start_controller.rb
  2. 1
      spec/features/start_page_spec.rb
  3. 2
      spec/features/user_spec.rb
  4. 4
      spec/requests/auth/passwords_controller_spec.rb
  5. 1
      spec/requests/users_controller_spec.rb

6
app/controllers/start_controller.rb

@ -1,3 +1,7 @@
class StartController < ApplicationController
def index; end
def index
if current_user
redirect_to(case_logs_path)
end
end
end

1
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

2
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

4
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

1
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')}</a>"
follow_redirect!
expect(CGI.unescape_html(response.body)).to include(expected_link)
end
end

Loading…
Cancel
Save