Allow accepting all cookies in consent banner and management component

Create cookie consent "all" when accept all cookies

Set cookie duration to 365 days based on the AEPD's cookie usage guidelines.

Note from the document: "Cookies with a duration of up to 24 months are
considered acceptable as long as they are periodically updated."
Reference: https://www.aepd.es/guias/guia-cookies.pdf
This commit is contained in:
taitus
2024-12-09 16:07:26 +01:00
parent 6753505e7c
commit dc54fda71b
11 changed files with 86 additions and 0 deletions

View File

@@ -21,12 +21,14 @@ describe Layout::CookiesConsent::BannerComponent do
it "renders the banner content when feature `cookies_consent` is enabled and cookies were not accepted" do
Setting["cookies_consent.more_info_link"] = "/cookies_policy"
create(:cookies_vendor)
render_inline Layout::CookiesConsent::BannerComponent.new
expect(page).to be_rendered
expect(page).to have_css "h2", text: "Cookies policy"
expect(page).to have_link "More information about cookies", href: "/cookies_policy"
expect(page).to have_button "Accept all"
expect(page).to have_button "Accept essential cookies"
expect(page).to have_button "Manage cookies"
end
@@ -39,4 +41,11 @@ describe Layout::CookiesConsent::BannerComponent do
expect(page).not_to have_link "More information about cookies"
expect(page).to be_rendered
end
it "does not render an `Accept all` button when there aren't any cookie vendors" do
render_inline Layout::CookiesConsent::BannerComponent.new
expect(page).not_to have_button "Accept all"
expect(page).to be_rendered
end
end

View File

@@ -13,6 +13,7 @@ describe Layout::CookiesConsent::ManagementComponent do
it "is rendered when the cookies consent is enabled" do
Setting["cookies_consent.more_info_link"] = "/cookies_policy"
create(:cookies_vendor)
render_inline Layout::CookiesConsent::ManagementComponent.new
@@ -21,6 +22,7 @@ describe Layout::CookiesConsent::ManagementComponent do
expect(page).to have_link "More information about cookies", href: "/cookies_policy"
expect(page).to have_css "h3", text: "Essential cookies"
expect(page).to have_css ".switch-input[type='checkbox'][name='essential_cookies'][disabled][checked]"
expect(page).to have_button "Accept all"
expect(page).to have_button "Accept essential cookies"
end
@@ -32,4 +34,11 @@ describe Layout::CookiesConsent::ManagementComponent do
expect(page).not_to have_link "More information about cookies"
expect(page).to be_rendered
end
it "does not render an `Accept all` button when there aren't any cookie vendors" do
render_inline Layout::CookiesConsent::ManagementComponent.new
expect(page).not_to have_button "Accept all"
expect(page).to be_rendered
end
end