diff --git a/app/views/shared/_header.html.erb b/app/views/shared/_header.html.erb index e3eeff304..06e0fbc54 100644 --- a/app/views/shared/_header.html.erb +++ b/app/views/shared/_header.html.erb @@ -1,13 +1,17 @@ <% if header.present? %> -
+
"> <%= header.label %>

<%= header.title %>

+

<%= header.description %>

-
"> - <%= link_to header.link_text, header.link_url, class: "button expanded large" %> -
+ + <% if header.link_text.present? && header.link_url.present? %> +
"> + <%= link_to header.link_text, header.link_url, class: "button expanded large" %> +
+ <% end %>
<% if header.image.present? %> diff --git a/spec/system/home_spec.rb b/spec/system/home_spec.rb index f1482e2d9..6a2a36456 100644 --- a/spec/system/home_spec.rb +++ b/spec/system/home_spec.rb @@ -174,4 +174,30 @@ describe "Home" do expect(page).not_to have_css(".title", text: "Featured") end + + describe "Header Card" do + scenario "if there is header card with link, the link content is rendered" do + create(:widget_card, :header, link_text: "Link text", link_url: "consul.dev") + + visit root_path + + expect(page).to have_link "Link text", href: "consul.dev" + end + + scenario "if there is header card without link, the link content is not rendered" do + create(:widget_card, :header, link_text: nil, link_url: nil) + + visit root_path + + within(".header-card") { expect(page).not_to have_link } + end + + scenario "if there is header card without link and with text, the link content is not rendered" do + create(:widget_card, :header, link_text: "", link_url: "", link_text_es: "Link ES", title_es: "ES") + + visit root_path(locale: :es) + + within(".header-card") { expect(page).not_to have_link } + end + end end