Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow unauthenticated user to view the terms and conditions page #362

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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="[email protected]">Email: [email protected]</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
Loading