From 357b3406ed1d0a531b2b48f2de1e982339726d97 Mon Sep 17 00:00:00 2001 From: Papaya Labs Date: Thu, 13 Sep 2018 15:33:24 -0500 Subject: [PATCH 1/2] Hide Featured section on Home Page if there are no cards --- app/views/welcome/index.html.erb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index e2ae116e1..367392a27 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -20,9 +20,11 @@
-
- <%= render "cards" %> -
+ <% if @cards.any? %> +
+ <%= render "cards" %> +
+ <% end %>
<%= render "processes" %> From f7c10de6274bab6232273dde7ed0713cd5883277 Mon Sep 17 00:00:00 2001 From: Papaya Labs Date: Tue, 18 Sep 2018 15:16:31 -0500 Subject: [PATCH 2/2] Fix indentation and include specs --- app/views/welcome/index.html.erb | 4 ++-- spec/features/home_spec.rb | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 367392a27..b8ee72235 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -20,11 +20,11 @@
- <% if @cards.any? %> + <% if @cards.any? %>
<%= render "cards" %>
- <% end %> + <% end %>
<%= render "processes" %> diff --git a/spec/features/home_spec.rb b/spec/features/home_spec.rb index 7f90f54c1..7f8f1eb46 100644 --- a/spec/features/home_spec.rb +++ b/spec/features/home_spec.rb @@ -143,4 +143,24 @@ feature "Home" do "/html/body/div[@class='wrapper ']/comment()[contains(.,'ie-callout')]" end end + + + scenario 'if there are cards, the "featured" title will render' do + card = create(:widget_card, + title: "Card text", + description: "Card description", + link_text: "Link text", + link_url: "consul.dev" + ) + + visit root_path + + expect(page).to have_css(".title", text: "Featured") + end + + scenario 'if there are no cards, the "featured" title will not render' do + visit root_path + + expect(page).not_to have_css(".title", text: "Featured") + end end