Skip to content

Commit

Permalink
Add footer billboard (forem#21190)
Browse files Browse the repository at this point in the history
  • Loading branch information
benhalpern authored Jul 31, 2024
1 parent 7ff071b commit 8523c54
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/billboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Billboard < ApplicationRecord
feed_second
feed_third
home_hero
footer
page_fixed_bottom
post_fixed_bottom
post_body_bottom
Expand All @@ -32,6 +33,7 @@ class Billboard < ApplicationRecord
"Home Feed Second",
"Home Feed Third",
"Home Hero",
"Footer",
"Fixed Bottom (Page)",
"Fixed Bottom (Individual Post)",
"Below the post body",
Expand Down
10 changes: 10 additions & 0 deletions app/views/layouts/_footer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@
}
end %>


<footer id="footer" class="crayons-footer print-hidden">
<div id="footer-container" class="crayons-footer__container">


<% cache "footer-billboard-#{user_signed_in?}", expires_in: 30.minutes do %>
<% footer_billboard = Billboard.for_display(area: "footer", user_signed_in: user_signed_in?) %>
<% if footer_billboard %>
<%= render partial: "shared/billboard", locals: { billboard: footer_billboard, data_context_type: BillboardEvent::CONTEXT_TYPE_HOME } %>
<% end %>
<% end %>

<p class="fs-s crayons-footer__description">
<%= t("views.main.footer.desc_html", community: link_to(community_name, root_path, class: "c-link c-link--branded fw-medium", "aria-label": t("views.main.aria_home", community: community_name)), desc: Settings::Community.community_description) %>
</p>
Expand Down
6 changes: 6 additions & 0 deletions spec/requests/stories_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ def renders_ga_tracking_fields
expect(response.body).to include(billboard.processed_html)
end

it "renders a footer billboard" do
billboard = create(:billboard, published: true, approved: true, placement_area: "footer", organization: org)
get "/"
expect(response.body).to include(billboard.processed_html)
end

it "does not set cache-related headers if private" do
allow(Settings::UserExperience).to receive(:public).and_return(false)
get "/"
Expand Down

0 comments on commit 8523c54

Please sign in to comment.