Skip to content

Commit

Permalink
Applied change to ensure GA is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
tahir-khalid committed Oct 15, 2024
1 parent fcf14e8 commit b4f2e92
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/controllers/concerns/cookies_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module CookiesConcern

def set_cookie_form
@cookie_form = CookieForm.new(accept_analytics_cookies: analytics_cookies)
set_analytics_cookies(analytics_cookies)
end

def try_to_clear_non_essential_cookies
Expand Down Expand Up @@ -49,7 +50,8 @@ def set_analytics_cookies(accept_analytics_cookies)
cookies[:cookies_policy] = {
value: get_policy.to_json,
expires: 1.year.from_now,
httponly: true
httponly: true,
raw: true
}
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_ga_head.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-K2S954RK');</script>
})(window,document,'script','dataLayer','GTM-MW2FHD2N');</script>
<!-- End Google Tag Manager -->
6 changes: 6 additions & 0 deletions spec/features/cookie_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
We’d also like to use analytics cookies so we can understand how you use the service and make improvements."
end

before(:each) do
Capybara.current_session.driver.browser.manage.delete_all_cookies
end

scenario "when the user accepts analytics cookies and changes their mind" do
visit("/")
expect(page).to have_text(cookie_banner_text)

byebug

click_button("Accept analytics cookies")
expect(page).to have_text("You’ve accepted additional cookies.")
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/cookies_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

it "has analytics cookies" do
# response is not returning any cookies to delete
expect(cookies.to_hash.size).to eq(6)
expect(cookies.to_hash.size).to eq(7)
end
end

Expand Down

0 comments on commit b4f2e92

Please sign in to comment.