Skip to content

Commit

Permalink
Merge pull request #362 from DFE-Digital/allow-unauthenticated-user-t…
Browse files Browse the repository at this point in the history
…o-view-terms-and-conditions-page

Allow unauthenticated user to view the terms and conditions page
  • Loading branch information
richardpattinson authored Jul 12, 2024
2 parents 2113f8c + 8ebd000 commit 461f292
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/controllers/terms_and_conditions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

class TermsAndConditionsController < ApplicationController
skip_before_action :authenticate_dsi_user!
skip_before_action :handle_expired_session!
skip_before_action :enforce_terms_and_conditions_acceptance!

def show
Expand Down
6 changes: 4 additions & 2 deletions app/views/terms_and_conditions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,10 @@
<p class="govuk-body"><a class="govuk-link" mailto="teaching.status@education.gov.uk">Email: teaching.status@education.gov.uk</a></p>

<p class="govuk-body">Website: <a class="govuk-link" href="https://www.gov.uk/government/organisations/teaching-regulation-agency">https://www.gov.uk/government/organisations/teaching-regulation-agency</a></p>
<%= form_with url: terms_and_conditions_path, method: :patch do |f| %>
<%= f.govuk_submit "Accept" %>
<% if current_dsi_user %>
<%= form_with url: terms_and_conditions_path, method: :patch do |f| %>
<%= f.govuk_submit "Accept" %>
<% end %>
<% end %>
</div>
</div>
13 changes: 13 additions & 0 deletions spec/system/user_accepts_terms_and_conditions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

scenario "User accepts terms and conditions", test: :with_stubbed_auth do
given_the_service_is_open
when_i_visit_the_sign_in_page
and_i_click_on_terms_and_conditions_footer_link
then_i_am_redirected_to_the_terms_and_conditions_page
and_the_accept_button_is_hidden

when_i_sign_in_via_dsi(accept_terms_and_conditions: false)
then_i_am_signed_in
and_i_am_redirected_to_the_terms_and_conditions_page
Expand Down Expand Up @@ -49,6 +54,14 @@ def and_i_am_redirected_to_the_terms_and_conditions_page
:and_i_am_redirected_to_the_terms_and_conditions_page,
)

def and_i_click_on_terms_and_conditions_footer_link
click_link "Terms and conditions"
end

def and_the_accept_button_is_hidden
expect(page).not_to have_link "Accept"
end

def when_i_click_accept
click_on "Accept"
end
Expand Down

0 comments on commit 461f292

Please sign in to comment.