diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 1fc4191ce4..8c73a855eb 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -8,19 +8,7 @@ class HomeController < BaseController end def temp_landing_page - @regions = [] - - DISTRIBUTOR_CONFIG[Rails.env]["regions"].each do |region_data| - region = {} - region[:name] = region_data["name"] - distributors = [] - region_data["distributors"].each do |distributor_data| - enterprise = Enterprise.find_by_name(distributor_data["name"]) - distributors << enterprise if !enterprise.nil? && enterprise.is_distributor - end - region[:distributors] = distributors - @regions << region - end + @groups = EnterpriseGroup.on_front_page render layout: false end diff --git a/app/views/home/temp_landing_page.html.haml b/app/views/home/temp_landing_page.html.haml index b364dd6d48..762ac9b699 100644 --- a/app/views/home/temp_landing_page.html.haml +++ b/app/views/home/temp_landing_page.html.haml @@ -30,11 +30,11 @@ %h3 WHERE WOULD YOU LIKE TO SHOP? %p.secondary Select your hub from the list below .row.landing-page-row.with-bottom-border - - @regions.each do |region| + - @groups.each do |group| .large-3.columns .region-header - %h5= region[:name].upcase - - region[:distributors].each do |distributor| + %h5= group.name.upcase + - group.enterprises.is_distributor.each do |distributor| .row.distributor-link-row .large-12.columns = succeed ',' do diff --git a/config/distributors.yml b/config/distributors.yml deleted file mode 100644 index 09a8c6b6ce..0000000000 --- a/config/distributors.yml +++ /dev/null @@ -1,67 +0,0 @@ ---- - -development: &test - regions: - - name: "Inner Melbourne" - distributors: - - name: "Green Grass" - - name: "AusFarmers United" - - name: "Blackburn FreeGrossers" - - name: "Melb Uni Co-op" - - name: "Edible garden" - - name: "FruitAndVeg" - - name: "MoreFreshStuff" - - - name: "South East Melbourne" - distributors: - - name: "MegaFoods" - - name: "Eco Butchers" - - name: "Eastern Wines" - - name: "QuickFresh" - - - name: "Mildura" - distributors: - - name: "Fooderers" - - name: "Food Local" - - - name: "South East Gippsland" - distributors: - - name: "Green Food Trading Corporation" - - name: "Better Food" - - name: "Gippsland Poultry" - -test: - <<: *test - -staging: - regions: - - name: "Inner Melbourne" - distributors: - - name: "Eaterprises (Ballantyne)" - - name: "PepperTree Place" - - name: "Childcare Center" - - name: "Bulk Foods Coop" - - name: "Sporting Club" - - - name: "South East Melbourne" - distributors: - - name: "South East Food Hub" - - name: "Primary School" - - name: "Farmers Market" - - name: "Neighbourhood Coop" - - - name: "Regional Victoria" - distributors: - - name: "SW Food Hub" - - name: "Farmer Coop" - - name: "Mildura Food Centre" - - name: "Grow Lightly (Korumburra)" - - -production: - regions: - - name: "Eaterprises" - distributors: - - name: "Murundaka (Heidelberg)" - - name: "Ballantyne (Thornbury)" - - name: "O'Hea Street, Coburg" diff --git a/config/initializers/distributors.rb b/config/initializers/distributors.rb deleted file mode 100644 index e7815092f3..0000000000 --- a/config/initializers/distributors.rb +++ /dev/null @@ -1,3 +0,0 @@ -# YAML distributors config -DISTRIBUTOR_CONFIG = YAML.load(File.read(File.expand_path('../../distributors.yml', __FILE__))) -DISTRIBUTOR_CONFIG.merge! DISTRIBUTOR_CONFIG.fetch(Rails.env, {}) diff --git a/spec/features/consumer/temp_landing_page_spec.rb b/spec/features/consumer/temp_landing_page_spec.rb index 29329ee171..522b066f8a 100644 --- a/spec/features/consumer/temp_landing_page_spec.rb +++ b/spec/features/consumer/temp_landing_page_spec.rb @@ -3,14 +3,18 @@ require 'spec_helper' feature %q{ As a consumer I want to see the landing page - So I choose a distributor + So I can choose a distributor }, js: true do include AuthenticationWorkflow background do - # for the link to be visible, it would also have to be in 'distributors.yml' - FactoryGirl.create(:address, :address1 => "25 Myrtle Street", :zipcode => "3153", :city => "Bayswater") - FactoryGirl.create(:distributor_enterprise, :name => "Green Grass", :address => Spree::Address.find_by_zipcode("3153")) + 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 @@ -40,13 +44,18 @@ feature %q{ end describe "hub list" do - it "should display hub link" do - page.should have_link "Green Grass" + it "should display grouped hubs" do + page.should have_content 'GROUP ONE' + page.should have_link 'Murandaka' + page.should have_link 'Ballantyne' + + page.should have_content 'GROUP TWO' + page.should have_link "O'Hea Street" end it "should link to the hub page" do - click_on "Green Grass" - page.should have_content "CART" + click_on 'Murandaka' + page.should have_content 'CART' end end