From fdf80cac5ed95da3a114eeecf770bef69f007d03 Mon Sep 17 00:00:00 2001 From: alexs Date: Tue, 20 Aug 2013 16:14:29 +1000 Subject: [PATCH] Adjusted specs to accommodate for new (temporary) landing page. --- config/distributors.yml | 4 ++++ spec/features/consumer/add_to_cart_spec.rb | 6 ++--- .../features/consumer/browse_products_spec.rb | 10 ++++----- spec/features/consumer/checkout_spec.rb | 22 +++++++++++++------ spec/features/consumer/cms_spec.rb | 16 +++++--------- spec/features/consumer/distributors_spec.rb | 15 +++++++++---- spec/features/consumer/suppliers_spec.rb | 9 ++++++++ spec/features/consumer/taxonomy_spec.rb | 17 ++++++++++---- spec/spec_helper.rb | 2 +- 9 files changed, 67 insertions(+), 34 deletions(-) diff --git a/config/distributors.yml b/config/distributors.yml index bf96044d18..f197961415 100644 --- a/config/distributors.yml +++ b/config/distributors.yml @@ -7,6 +7,10 @@ development: &test - 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: diff --git a/spec/features/consumer/add_to_cart_spec.rb b/spec/features/consumer/add_to_cart_spec.rb index e5025aff5d..259c21fe1a 100644 --- a/spec/features/consumer/add_to_cart_spec.rb +++ b/spec/features/consumer/add_to_cart_spec.rb @@ -27,7 +27,7 @@ feature %q{ Spree::Order.last.line_items.should be_empty end - scenario "adding the first product to the cart" do + scenario "adding the first product to the cart", :future => true do # Given a product, some distributors and a defined shipping cost d1 = create(:distributor_enterprise, :name => "Green Grass") d2 = create(:distributor_enterprise, :name => "AusFarmers United") @@ -42,11 +42,11 @@ feature %q{ # When I choose a distributor visit spree.root_path - click_link d2.name + click_on "AusFarmers United" # And I add an item to my cart from a different distributor visit spree.product_path p - select d1.name, :from => 'distributor_id' + select(d1.name, :from => 'distributor_id') click_button 'Add To Cart' # Then the correct totals should be displayed diff --git a/spec/features/consumer/browse_products_spec.rb b/spec/features/consumer/browse_products_spec.rb index 31cb2a6bfc..fbc5113efe 100644 --- a/spec/features/consumer/browse_products_spec.rb +++ b/spec/features/consumer/browse_products_spec.rb @@ -32,6 +32,7 @@ feature %q{ # When I select the distributor visit spree.select_distributor_order_path(d) visit spree.root_path + click_on "Melb Uni Co-op" # Then I should see the name of the distributor that I've selected page.should have_content 'You are shopping at Melb Uni Co-op' @@ -54,8 +55,7 @@ feature %q{ # Then I should see products split by local/remote distributor # on the home page, the products page, the search results page and the taxon page - [spree.root_path, - spree.products_path, + [spree.products_path, spree.products_path(:keywords => 'Product'), spree.nested_taxons_path(taxon.permalink) ].each do |path| @@ -146,7 +146,7 @@ feature %q{ taxonomy = Spree::Taxonomy.find_by_name('Products') || create(:taxonomy, :name => 'Products') taxonomy_root = taxonomy.root taxon = create(:taxon, :name => 'Taxon one', :parent_id => taxonomy_root.id) - d1 = create(:distributor_enterprise) + d1 = create(:distributor_enterprise, :name => "Melb Uni Co-op") d2 = create(:distributor_enterprise) p1 = create(:product, :taxons => [taxon]) p2 = create(:product, :taxons => [taxon]) @@ -155,13 +155,13 @@ feature %q{ # When I select the first order cycle visit spree.root_path + click_on "Melb Uni Co-op" choose oc1.name click_button 'Choose Order Cycle' # Then I should see the products split by local/remote order cycle # on the home page, the products page, the search results page and the taxon page - [spree.root_path, - spree.products_path, + [spree.products_path, spree.products_path(:keywords => 'Product'), spree.nested_taxons_path(taxon.permalink) ].each do |path| diff --git a/spec/features/consumer/checkout_spec.rb b/spec/features/consumer/checkout_spec.rb index b58a627c41..562ea7ad36 100644 --- a/spec/features/consumer/checkout_spec.rb +++ b/spec/features/consumer/checkout_spec.rb @@ -74,6 +74,7 @@ feature %q{ scenario "viewing delivery fees for product distribution" do # Given I am logged in login_to_consumer_section + click_link "Edible garden" # When I add some apples and some garlic to my cart click_link 'Fuji apples' @@ -98,6 +99,7 @@ feature %q{ # And I am logged in login_to_consumer_section + click_link "FruitAndVeg" # When I add some bananas and zucchini to my cart click_link 'Bananas' @@ -113,14 +115,14 @@ feature %q{ checkout_fees_table.should == [["Bananas - packing fee by supplier Supplier 1", "$3.00", ""], ["Bananas - transport fee by supplier Supplier 1", "$4.00", ""], - ["Bananas - packing fee by distributor Distributor 1", "$7.00", ""], - ["Bananas - transport fee by distributor Distributor 1", "$8.00", ""], + ["Bananas - packing fee by distributor FruitAndVeg", "$7.00", ""], + ["Bananas - transport fee by distributor FruitAndVeg", "$8.00", ""], ["Bananas - admin fee by coordinator My coordinator", "$1.00", ""], ["Bananas - sales fee by coordinator My coordinator", "$2.00", ""], ["Zucchini - admin fee by supplier Supplier 2", "$5.00", ""], ["Zucchini - sales fee by supplier Supplier 2", "$6.00", ""], - ["Zucchini - packing fee by distributor Distributor 1", "$7.00", ""], - ["Zucchini - transport fee by distributor Distributor 1", "$8.00", ""], + ["Zucchini - packing fee by distributor FruitAndVeg", "$7.00", ""], + ["Zucchini - transport fee by distributor FruitAndVeg", "$8.00", ""], ["Zucchini - admin fee by coordinator My coordinator", "$1.00", ""], ["Zucchini - sales fee by coordinator My coordinator", "$2.00", ""]] @@ -137,6 +139,7 @@ feature %q{ # And I am logged in login_to_consumer_section + click_link "Edible garden" # When I add the first to my cart click_link 'Fuji apples' @@ -154,6 +157,7 @@ feature %q{ scenario "removing a product from cart removes its fees", js: true do # Given I am logged in login_to_consumer_section + click_link "Edible garden" # When I add some apples and some garlic to my cart click_link 'Fuji apples' @@ -178,6 +182,7 @@ feature %q{ scenario "adding products with differing quantities produces correct fees" do # Given I am logged in login_to_consumer_section + click_link "Edible garden" # When I add two products to my cart that share the same enterprise fee click_link 'Fuji apples' @@ -207,7 +212,7 @@ feature %q{ scenario "changing distributor updates delivery fees" do # Given two distributors and enterprise fees - d1 = create(:distributor_enterprise) + d1 = create(:distributor_enterprise, :name => "FruitAndVeg") d2 = create(:distributor_enterprise) ef1 = create(:enterprise_fee, calculator: Spree::Calculator::PerItem.new) ef1.calculator.set_preference :amount, 1.23; ef1.calculator.save! @@ -225,6 +230,7 @@ feature %q{ # When I add the first product to my cart with the first distributor #visit spree.root_path login_to_consumer_section + click_link "FruitAndVeg" click_link p1.name select d1.name, :from => 'distributor_id' click_button 'Add To Cart' @@ -245,6 +251,7 @@ feature %q{ scenario "adding a product to cart after emptying cart shows correct delivery fees" do # When I add a product to my cart login_to_consumer_section + click_link "Edible garden" click_link @product_1.name select @distributor.name, :from => 'distributor_id' click_button 'Add To Cart' @@ -265,6 +272,7 @@ feature %q{ scenario "buying a product", :js => true do login_to_consumer_section + click_link "Edible garden" click_link 'Fuji apples' select @distributor.name, :from => 'distributor_id' @@ -352,8 +360,8 @@ feature %q{ ExchangeFee.create!(exchange: ex2, enterprise_fee: supplier_fee4) # Distributors - distributor1 = create(:distributor_enterprise, name: 'Distributor 1') - distributor2 = create(:distributor_enterprise, name: 'Distributor 2') + distributor1 = FactoryGirl.create(:distributor_enterprise, name: "FruitAndVeg") + distributor2 = FactoryGirl.create(:distributor_enterprise, name: "MoreFreshStuff") distributor_fee1 = create(:enterprise_fee, enterprise: distributor1, fee_type: 'packing', amount: 7) distributor_fee2 = create(:enterprise_fee, enterprise: distributor1, fee_type: 'transport', amount: 8) distributor_fee3 = create(:enterprise_fee, enterprise: distributor2, fee_type: 'admin', amount: 9) diff --git a/spec/features/consumer/cms_spec.rb b/spec/features/consumer/cms_spec.rb index 7cd085f1e4..660b05e162 100644 --- a/spec/features/consumer/cms_spec.rb +++ b/spec/features/consumer/cms_spec.rb @@ -8,16 +8,8 @@ feature %q{ include AuthenticationWorkflow include WebHelper - - scenario "viewing the home page" do - # Given a CMS home page - create(:cms_page, content: 'Home page content') - - # When I visit the home page - visit spree.root_path - - # Then I should see my content - page.should have_content 'Home page content' + background do + create(:distributor_enterprise, :name => 'Edible garden') end scenario "viewing another products listing page does not display home page content" do @@ -41,6 +33,9 @@ feature %q{ # When I visit the home page visit spree.root_path + # and proceed to the shop front + click_on "Edible garden" + # Then I should see a menu with these pages page.should have_selector 'ul#main-nav-bar li', :text => 'One' page.should have_selector 'ul#main-nav-bar li', :text => 'Two' @@ -56,6 +51,7 @@ feature %q{ # When I go to one of the pages visit spree.root_path + click_on "Edible garden" click_link 'Two' # Then I should see the page diff --git a/spec/features/consumer/distributors_spec.rb b/spec/features/consumer/distributors_spec.rb index 2ca470ac56..e330953200 100644 --- a/spec/features/consumer/distributors_spec.rb +++ b/spec/features/consumer/distributors_spec.rb @@ -10,7 +10,7 @@ feature %q{ scenario "viewing a list of distributors in the sidebar" do # Given some distributors - d1 = create(:distributor_enterprise) + d1 = create(:distributor_enterprise, :name => "Edible garden") d2 = create(:distributor_enterprise) d3 = create(:distributor_enterprise) @@ -20,6 +20,9 @@ feature %q{ # When I go to the home page visit spree.root_path + # and proceed to the shop front + click_on "Edible garden" + # Then I should see a list containing the distributors that have products page.should have_selector 'a', :text => d1.name page.should have_selector 'a', :text => d2.name @@ -28,7 +31,7 @@ feature %q{ scenario "viewing a list of distributors (with active products) in the sidebar when there's some inactive distributors" do # Given some distributors - d1 = create(:distributor_enterprise) + d1 = create(:distributor_enterprise, :name => "Edible garden") d2 = create(:distributor_enterprise) d3 = create(:distributor_enterprise) d4 = create(:distributor_enterprise) @@ -45,6 +48,9 @@ feature %q{ # When I go to the home page visit spree.root_path + # and proceed to the shop front + click_on "Edible garden" + # Then I should see a list containing all the distributors that have active products in stock page.should have_selector 'a', :text => d1.name page.should_not have_selector 'a', :text => d2.name #has no products @@ -60,7 +66,7 @@ feature %q{ scenario "viewing a list of all distributors" do # Given some distributors - d1 = create(:distributor_enterprise) + d1 = create(:distributor_enterprise, :name => "Edible garden") d2 = create(:distributor_enterprise) d3 = create(:distributor_enterprise) @@ -70,6 +76,7 @@ feature %q{ # When I go to the distributors listing page visit spree.root_path + click_on "Edible garden" click_button 'Browse All Distributors' # Then I should see a list containing all the distributors @@ -81,7 +88,7 @@ feature %q{ scenario "viewing a distributor" do # Given some distributors with products - d1 = create(:distributor_enterprise, :long_description => "

Hello, world!

") + d1 = create(:distributor_enterprise, :name => "Edible garden", :long_description => "

Hello, world!

") d2 = create(:distributor_enterprise) p1 = create(:product, :distributors => [d1]) p2 = create(:product, :distributors => [d2]) diff --git a/spec/features/consumer/suppliers_spec.rb b/spec/features/consumer/suppliers_spec.rb index 2dee0f1a5f..e14c49a2f3 100644 --- a/spec/features/consumer/suppliers_spec.rb +++ b/spec/features/consumer/suppliers_spec.rb @@ -8,6 +8,10 @@ feature %q{ include AuthenticationWorkflow include WebHelper + background do + create(:distributor_enterprise, :name => "Edible garden") + end + scenario "viewing a list of suppliers (with active products) in the sidebar when there's 5 or fewer" do # Given some suppliers s1 = create(:supplier_enterprise) @@ -27,6 +31,9 @@ feature %q{ # When I go to the home page visit spree.root_path + # and proceed to the shop front + click_on "Edible garden" + # Then I should see a list containing all the suppliers that have active products in stock page.should have_selector 'a', :text => s1.name page.should_not have_selector 'a', :text => s2.name #has no products @@ -52,6 +59,7 @@ feature %q{ # When I go to the suppliers listing page visit spree.root_path + click_on "Edible garden" click_button 'Browse All Suppliers' # Then I should see a list containing all the suppliers @@ -71,6 +79,7 @@ feature %q{ # When I select the first supplier visit spree.root_path + click_on "Edible garden" click_link s1.name # Then I should see the supplier details diff --git a/spec/features/consumer/taxonomy_spec.rb b/spec/features/consumer/taxonomy_spec.rb index 15e2339c7a..8b0667ec45 100644 --- a/spec/features/consumer/taxonomy_spec.rb +++ b/spec/features/consumer/taxonomy_spec.rb @@ -8,6 +8,10 @@ feature %q{ include AuthenticationWorkflow include WebHelper + background do + create(:distributor_enterprise, :name => "Edible garden") + end + # How should this work with distributors/order cycles? # - No distributor or OC selected - all shown # - Distributor selected - any from that distributor in any OC @@ -16,7 +20,7 @@ feature %q{ # Also keep specs for distributors outside order cycles. - scenario "viewing product counts when no distributor or order cycle is selected" do + scenario "viewing product counts when no distributor or order cycle is selected", :future => true do # Given some taxons and some products taxonomy = Spree::Taxonomy.find_by_name('Products') || create(:taxonomy, :name => 'Products') taxonomy_root = taxonomy.root @@ -32,6 +36,9 @@ feature %q{ # When I visit the home page visit spree.root_path + # and proceed to the shop front + click_on "Edible garden" + # Then I should see product counts next to the taxons page.should have_selector 'nav#taxonomies li', :text => 'Taxon one (1)' page.should have_selector 'nav#taxonomies li', :text => 'Taxon two (2)' @@ -39,7 +46,7 @@ feature %q{ end - scenario "viewing product counts when a distributor is selected" do + scenario "viewing product counts when a distributor is selected", :future => true do # Given some taxons and some products under distributors taxonomy = Spree::Taxonomy.find_by_name('Products') || create(:taxonomy, :name => 'Products') taxonomy_root = taxonomy.root @@ -81,7 +88,7 @@ feature %q{ end end - scenario "viewing product counts when an order cycle is selected" do + scenario "viewing product counts when an order cycle is selected", :future => true do # Given some taxons and some products and some order cycles taxonomy = Spree::Taxonomy.find_by_name('Products') || create(:taxonomy, :name => 'Products') taxonomy_root = taxonomy.root @@ -104,6 +111,7 @@ feature %q{ # When I visit the home page and select my order cycle visit root_path + click_on "Edible garden" choose oc2.name click_button 'Choose Order Cycle' page.should have_content 'Your order cycle has been selected.' @@ -114,7 +122,7 @@ feature %q{ page.should have_selector 'nav#taxonomies li', :text => 'Taxon three (2)' end - scenario "viewing product counts when both a distributor and an order cycle are selected" do + scenario "viewing product counts when both a distributor and an order cycle are selected", :future => true do # Given some taxons and some products under distributors taxonomy = Spree::Taxonomy.find_by_name('Products') || create(:taxonomy, :name => 'Products') taxonomy_root = taxonomy.root @@ -145,6 +153,7 @@ feature %q{ within('nav#filters') { click_link my_distributor.name } page.should have_content 'You are shopping at My Distributor' visit root_path + click_on "Edible garden" choose oc2.name click_button 'Choose Order Cycle' page.should have_content 'Your order cycle has been selected.' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a60cc125a3..20d9668177 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -57,7 +57,7 @@ RSpec.configure do |config| # ## Filters # - config.filter_run_excluding :skip => true + config.filter_run_excluding :skip => true, :future => true config.before(:each) do Spree::Address.any_instance.stub(:geocode).and_return([1,1])