From 927970d1a9fbbff3746fcd40b898e75f417c327c Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 12 Oct 2012 09:39:49 +1100 Subject: [PATCH] Viewing another products listing page does not display home page content --- app/helpers/application_helper.rb | 5 +++++ .../spree/shared/_products_by_distributor.html.haml | 2 +- spec/requests/consumer/cms_spec.rb | 12 ++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be7945c..db628debaf 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,7 @@ module ApplicationHelper + def home_page_cms_content + if controller.controller_name == 'home' && controller.action_name == 'index' + cms_page_content(:content, Cms::Page.find_by_full_path('/')) + end + end end diff --git a/app/views/spree/shared/_products_by_distributor.html.haml b/app/views/spree/shared/_products_by_distributor.html.haml index ea5de13e9c..34da323228 100644 --- a/app/views/spree/shared/_products_by_distributor.html.haml +++ b/app/views/spree/shared/_products_by_distributor.html.haml @@ -1,4 +1,4 @@ -= cms_page_content(:content, Cms::Page.find_by_full_path('/')) += home_page_cms_content - if @products #products= render 'spree/shared/products', :products => @products, :taxon => @taxon diff --git a/spec/requests/consumer/cms_spec.rb b/spec/requests/consumer/cms_spec.rb index 7f5d918446..93a6a87958 100644 --- a/spec/requests/consumer/cms_spec.rb +++ b/spec/requests/consumer/cms_spec.rb @@ -20,6 +20,18 @@ feature %q{ page.should have_content 'Home page content' end + scenario "viewing another products listing page does not display home page content" do + # Given a CMS home page + create(:cms_page, content: 'Home page content') + + # When I visit a products listing page + visit spree.products_path + + # Then I should not see the home page content + page.should_not have_content 'Home page content' + end + + scenario "viewing the menu of CMS pages" do # Given some CMS pages home_page = create(:cms_page, content: 'Home')