From 11c1df0bdd8631385d0072486cb46db196c5ee2e Mon Sep 17 00:00:00 2001 From: baarkerlounger <5101747+baarkerlounger@users.noreply.github.com> Date: Mon, 20 Dec 2021 14:36:18 +0000 Subject: [PATCH] Redirect to logs if they clicked start now (#175) --- app/controllers/auth/sessions_controller.rb | 6 ++++ app/views/devise/sessions/new.html.erb | 1 + app/views/start/index.html.erb | 3 +- spec/controllers/start_controller_spec.rb | 1 - spec/features/start_page_spec.rb | 31 +++++++++++++++++++++ 5 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 spec/features/start_page_spec.rb diff --git a/app/controllers/auth/sessions_controller.rb b/app/controllers/auth/sessions_controller.rb index a117aecff..270b89b2e 100644 --- a/app/controllers/auth/sessions_controller.rb +++ b/app/controllers/auth/sessions_controller.rb @@ -17,4 +17,10 @@ class Auth::SessionsController < Devise::SessionsController super end end + +private + + def after_sign_in_path_for(resource) + params.dig("user", "start").present? ? case_logs_path : super + end end diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 70a4bfc0e..edfe427a0 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -19,6 +19,7 @@ autocomplete: "current-password" %> + <%= f.hidden_field :start, value: request["start"] %> <%= f.govuk_submit "Sign in" %> diff --git a/app/views/start/index.html.erb b/app/views/start/index.html.erb index d3de2d344..7ba5625fa 100644 --- a/app/views/start/index.html.erb +++ b/app/views/start/index.html.erb @@ -16,9 +16,10 @@
The data will be used to update the national record for social housing. It will also help to inform policy about the cost of social housing and what type of housing needs to be built.
This service is only for social housing in England.
+ <% start_path = current_user ? case_logs_path : (user_session_path + "?start=true") %> <%= govuk_start_button( text: 'Start now', - href: user_session_path + href: start_path ) %>