Skip to content

Commit

Permalink
Include the cookies consent components in custom views
Browse files Browse the repository at this point in the history
  • Loading branch information
Senen committed Mar 8, 2024
1 parent cf8b6e6 commit 481804c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 7 deletions.
19 changes: 14 additions & 5 deletions app/components/custom/layout/footer_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,20 @@
<% end %>
</div>
<div class="small-12 large-2 column">
<%= link_to page_path("cookies") do %>
<div class="footer-link">
<%= image_tag(image_path_for("icono-cookies-footer.png"), alt: "") %>
<span><%= t("layouts.footer.links.cookies") %></span>
</div>
<% if cookies_setup_page_enabled? %>
<a href="#cookies_consent_setup" data-open="cookies_consent_setup">
<div class="footer-link">
<%= image_tag(image_path_for("icono-cookies-footer.png"), alt: "") %>
<span><%= t("layouts.footer.cookies_consent_setup") %></span>
</div>
</a>
<% else %>
<%= link_to page_path("cookies") do %>
<div class="footer-link">
<%= image_tag(image_path_for("icono-cookies-footer.png"), alt: "") %>
<span><%= t("layouts.footer.links.cookies") %></span>
</div>
<% end %>
<% end %>
</div>
<div class="small-12 large-2 column">
Expand Down
3 changes: 3 additions & 0 deletions app/views/custom/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<%= content_for :social_media_meta_tags %>

<%= raw setting["html.per_page_code_head"] %>
<%= render Cookies::Vendors::ScriptsComponent.new %>
</head>
<body class="<%= yield(:body_class) %> public">
<%= raw setting["html.per_page_code_body"] %>
Expand All @@ -27,6 +28,8 @@
<div class="footer">
<%= render Layout::FooterComponent.new %>
</div>
<%= render Layout::CookiesConsent::BannerComponent.new %>
<%= render Layout::CookiesConsent::SetupComponent.new %>
<div class="reveal" id="googleSearch" data-reveal>
<button class="close-button" data-close aria-label="Close modal" type="button">
<span aria-hidden="true">&times;</span>
Expand Down
27 changes: 27 additions & 0 deletions spec/components/custom/layout/footer_component_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require "rails_helper"

describe Layout::FooterComponent do
describe "when the cookies consent feature is enabled" do
before { Setting["feature.cookies_consent"] = true }

it "shows a link to the cookies setup modal when the cookies setup page is enabled" do
Setting["cookies_consent.setup_page"] = true

render_inline Layout::FooterComponent.new

page.find("footer") do |footer|
expect(footer).to have_css "a[data-open=cookies_consent_setup]", text: "Cookies setup"
end
end

it "does not show a link to the cookies setup modal when the cookies setup page is disabled" do
Setting["cookies_consent.setup_page"] = false

render_inline Layout::FooterComponent.new

page.find("footer") do |footer|
expect(footer).not_to have_css "a[data-open=cookies_consent_setup]", text: "Cookies setup"
end
end
end
end
4 changes: 2 additions & 2 deletions spec/components/layout/footer_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
describe "when the cookies consent feature is enabled" do
before { Setting["feature.cookies_consent"] = true }

it "shows a link to the cookies setup modal when the cookies setup page is enabled" do
it "shows a link to the cookies setup modal when the cookies setup page is enabled", :consul do
Setting["cookies_consent.setup_page"] = true

render_inline Layout::FooterComponent.new
Expand All @@ -27,7 +27,7 @@
end
end

it "does not show a link to the cookies setup modal when the cookies setup page is disabled" do
it "does not show a link to the cookies setup modal when the cookies setup page is disabled", :consul do
Setting["cookies_consent.setup_page"] = false

render_inline Layout::FooterComponent.new
Expand Down

0 comments on commit 481804c

Please sign in to comment.