Skip to content

Commit

Permalink
New cookie consent for Clarity and VWO cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
starswan committed Oct 24, 2024
1 parent 6278337 commit c8d6b88
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def not_found(_error = nil)
private

def show_cookies_banner?
cookies["consented-to-additional-cookies"].blank?
cookies["consented-to-additional-cookies-clarity-vwo"].blank?
end
helper_method :show_cookies_banner?

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/cookies_preferences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ class CookiesPreferencesController < ApplicationController
before_action :set_previous_url_in_session

def new
@cookies_preferences_form = CookiesPreferencesForm.new(cookies_consent: cookies["consented-to-additional-cookies"])
@cookies_preferences_form = CookiesPreferencesForm.new(cookies_consent: cookies["consented-to-additional-cookies-clarity-vwo"])
end

def create
@cookies_preferences_form = CookiesPreferencesForm.new(cookies_preferences_params)

if @cookies_preferences_form.valid?
cookies["consented-to-additional-cookies"] = { value: @cookies_preferences_form.cookies_consent,
cookies["consented-to-additional-cookies-clarity-vwo"] = { value: @cookies_preferences_form.cookies_consent,
expires: 6.months.from_now }

redirect_to(session[:previous_url], success: I18n.t("cookies_preferences.success")) unless params[:no_redirect]
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ def footer_links
end

def include_google_tag_manager?
cookies["consented-to-additional-cookies"] == "yes" && Rails.configuration.app_role.production?
cookies["consented-to-additional-cookies-clarity-vwo"] == "yes" && Rails.configuration.app_role.production?
end
end
2 changes: 1 addition & 1 deletion backstop/lib/playwright/loadCookies.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = async (browserContext, scenario, consent = true) => {

if (consent) {
cookies.push({
"name": "consented-to-additional-cookies",
"name": "consented-to-additional-cookies-clarity-vwo",
"value": "yes",
"domain": url.host,
"path": "/",
Expand Down
2 changes: 1 addition & 1 deletion config/locales/cookies_preferences.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ en:
We also use additional cookies to measure how you use the service and to help us with our marketing and communications.
heading: Cookies on Teaching Vacancies
subheading:
subheading:
settings: Cookie settings
additional: Additional cookies settings
title: Cookies
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/cookies_preferences_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
describe "POST #create" do
it "sets cookie value" do
post create_cookies_preferences_path, params: { cookies_consent: "yes" }
expect(response.cookies["consented-to-additional-cookies"]).to eq("yes")
expect(response.cookies["consented-to-additional-cookies-clarity-vwo"]).to eq("yes")
end
end
end
2 changes: 1 addition & 1 deletion spec/system/other/cookies_banner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def set_cookie(name, value)

context "when user has set their cookies preferences" do
before do
set_cookie("consented-to-additional-cookies", "yes")
set_cookie("consented-to-additional-cookies-clarity-vwo", "yes")
end

scenario "does not display the cookies banner" do
Expand Down

0 comments on commit c8d6b88

Please sign in to comment.