diff --git a/app/assets/stylesheets/search/temp_landing_page.css.scss b/app/assets/stylesheets/search/temp_landing_page.css.scss index 5a06088567..d0ac89a682 100644 --- a/app/assets/stylesheets/search/temp_landing_page.css.scss +++ b/app/assets/stylesheets/search/temp_landing_page.css.scss @@ -21,8 +21,12 @@ min-height: 200px; } +a.inactive { + color: #6a6a6a; +} + .secondary { - color: #6A6A6A; + color: #6a6a6a; } .group-header { diff --git a/app/helpers/temp_landing_page_helper.rb b/app/helpers/temp_landing_page_helper.rb index b511d9fae6..a187c5098f 100644 --- a/app/helpers/temp_landing_page_helper.rb +++ b/app/helpers/temp_landing_page_helper.rb @@ -1,9 +1,11 @@ module TempLandingPageHelper def temp_landing_page_distributor_link_class(distributor) cart = current_order(true) + @active_distributors ||= Enterprise.active_distributors klass = "shop-distributor" klass += " empties-cart" unless cart.line_items.empty? || cart.distributor == distributor + klass += @active_distributors.include?(distributor) ? ' active' : ' inactive' klass end end diff --git a/spec/features/consumer/temp_landing_page_spec.rb b/spec/features/consumer/temp_landing_page_spec.rb index 522b066f8a..52433605bb 100644 --- a/spec/features/consumer/temp_landing_page_spec.rb +++ b/spec/features/consumer/temp_landing_page_spec.rb @@ -7,14 +7,18 @@ feature %q{ }, js: true do include AuthenticationWorkflow + + let(:d1) { create(:distributor_enterprise, name: 'Murandaka') } + let(:d2) { create(:distributor_enterprise, name: 'Ballantyne') } + let(:d3) { create(:distributor_enterprise, name: "O'Hea Street") } + let(:d4) { create(:distributor_enterprise, name: "PepperTree Place") } + + let!(:eg1) { create(:enterprise_group, name: 'Group One', + on_front_page: true, enterprises: [d1, d2]) } + let!(:eg2) { create(:enterprise_group, name: 'Group Two', + on_front_page: true, enterprises: [d3, d4]) } + background do - d1 = create(:distributor_enterprise, name: 'Murandaka') - d2 = create(:distributor_enterprise, name: 'Ballantyne') - d3 = create(:distributor_enterprise, name: "O'Hea Street") - - eg1 = create(:enterprise_group, name: 'Group One', on_front_page: true, enterprises: [d1, d2]) - eg2 = create(:enterprise_group, name: 'Group Two', on_front_page: true, enterprises: [d3]) - visit root_path end @@ -51,6 +55,20 @@ feature %q{ page.should have_content 'GROUP TWO' page.should have_link "O'Hea Street" + page.should have_link "PepperTree Place" + end + + it "should grey out hubs that have no products available for distribution and are not in an order cycle" do + + create(:simple_order_cycle, distributors: [d1, d3]) + create(:simple_product, distributors: [d1, d2]) + + visit root_path + + page.should have_selector 'a.shop-distributor.active', text: 'Murandaka' + page.should have_selector 'a.shop-distributor.active', text: 'Ballantyne' + page.should have_selector 'a.shop-distributor.active', text: "O'Hea Street" + page.should have_selector 'a.shop-distributor.inactive', text: 'PepperTree Place' end it "should link to the hub page" do