-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implment terms and conditions acceptance
- Loading branch information
1 parent
0f397f6
commit 2aa2a15
Showing
15 changed files
with
370 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
class TermsAndConditionsController < ApplicationController | ||
skip_before_action :enforce_terms_and_conditions_acceptance! | ||
|
||
def show | ||
end | ||
|
||
def update | ||
current_dsi_user.accept_terms! | ||
redirect_to root_path, notice: "Terms and conditions accepted" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
db/migrate/20240711143411_add_terms_and_conditions_fields_to_dsi_user.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class AddTermsAndConditionsFieldsToDsiUser < ActiveRecord::Migration[7.1] | ||
def change | ||
change_table :dsi_users, bulk: true do |f| | ||
f.string :terms_and_conditions_version_accepted | ||
f.datetime :terms_and_conditions_accepted_at | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe "Terms and conditions acceptance", type: :system do | ||
include AuthenticationSteps | ||
|
||
scenario "User accepts terms and conditions", test: :with_stubbed_auth do | ||
given_the_service_is_open | ||
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 | ||
|
||
when_i_sign_out | ||
then_i_am_redirected_to_the_sign_in_page | ||
when_i_sign_in_via_dsi(accept_terms_and_conditions: false) | ||
then_i_am_redirected_to_the_terms_and_conditions_page | ||
|
||
when_i_go_to_the_root | ||
then_i_am_redirected_to_the_terms_and_conditions_page | ||
|
||
when_i_click_accept | ||
then_i_am_taken_to_the_root | ||
and_i_see_the_successful_notification | ||
and_the_dsi_user_has_been_updated | ||
|
||
when_13_months_has_passed | ||
when_i_go_to_the_root | ||
when_i_sign_in_via_dsi(accept_terms_and_conditions: false) | ||
then_i_am_redirected_to_the_terms_and_conditions_page | ||
when_i_click_accept | ||
then_i_am_taken_to_the_root | ||
and_i_see_the_successful_notification | ||
end | ||
|
||
private | ||
|
||
def then_i_am_signed_in | ||
within("header") { expect(page).to have_content "Sign out" } | ||
expect(DsiUser.count).to eq 1 | ||
expect(DsiUserSession.count).to eq 1 | ||
end | ||
|
||
def and_i_am_redirected_to_the_terms_and_conditions_page | ||
expect(page).to have_current_path("/terms-and-conditions") | ||
end | ||
alias_method( | ||
:then_i_am_redirected_to_the_terms_and_conditions_page, | ||
:and_i_am_redirected_to_the_terms_and_conditions_page, | ||
) | ||
|
||
def when_i_click_accept | ||
click_on "Accept" | ||
end | ||
|
||
def then_i_am_taken_to_the_root | ||
expect(page).to have_current_path("/search") | ||
end | ||
|
||
def and_i_see_the_successful_notification | ||
expect(page).to have_content "Terms and conditions accepted" | ||
end | ||
|
||
def and_the_dsi_user_has_been_updated | ||
expect(DsiUser.first.terms_and_conditions_version_accepted).to eq("1.0") | ||
expect(DsiUser.first.terms_and_conditions_accepted_at).to_not be(nil) | ||
end | ||
|
||
def when_13_months_has_passed | ||
travel_to 13.months.from_now | ||
end | ||
|
||
def when_i_go_to_the_root | ||
visit root_path | ||
end | ||
|
||
def when_i_sign_out | ||
click_on "Sign out" | ||
end | ||
|
||
def then_i_am_redirected_to_the_sign_in_page | ||
expect(page).to have_current_path(sign_in_path) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters