From 55277e2f0a05c261e9909c197c716f183fe66d2d Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 22 Jul 2013 14:55:46 +1000 Subject: [PATCH] test for inactive enterprises being counted in 'x more' on sidebar, disable limit test --- spec/features/consumer/distributors_spec.rb | 14 ++++++++++---- spec/features/consumer/suppliers_spec.rb | 12 +++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/spec/features/consumer/distributors_spec.rb b/spec/features/consumer/distributors_spec.rb index 4a75a8d8cc..549acca3f1 100644 --- a/spec/features/consumer/distributors_spec.rb +++ b/spec/features/consumer/distributors_spec.rb @@ -26,7 +26,7 @@ feature %q{ page.should_not have_selector 'a', :text => d3.name end -scenario "viewing a list of distributors (with active products) in the sidebar when there's 5 or fewer" do +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) d2 = create(:distributor_enterprise) @@ -39,6 +39,9 @@ scenario "viewing a list of distributors (with active products) in the sidebar w create(:product, :distributors => [d1]) create(:product, :distributors => [d3], :on_hand => 0) + # And no limit set for the sidebar + sidebar_distributors_limit = false + # When I go to the home page visit spree.root_path @@ -47,13 +50,15 @@ scenario "viewing a list of distributors (with active products) in the sidebar w page.should_not have_selector 'a', :text => d2.name #has no products page.should_not have_selector 'a', :text => d3.name #has no products on hand - # And I shouldn't see 'xx more' - page.should_not have_selector '#distributor_filter span.filter_more' + # And I should see '5 more' + distributors_more = Enterprise.is_distributor.distinct_count - Enterprise.is_distributor.with_distributed_active_products_on_hand.by_name.limit(sidebar_distributors_limit).length + page.should have_selector '#distributor_filter span.filter_more', :text => "#{distributors_more} more" - # And I shouldn't see a browse distributors button + # And I should (always) see a browse distributors button page.should have_selector "#distributor_filter input[value='Browse All Distributors']" end +=begin scenario "viewing a list of distributors (with active products) in the sidebar when there's more than 5" do # Given some distributors d1 = create(:distributor_enterprise) @@ -83,6 +88,7 @@ scenario "viewing a list of distributors (with active products) in the sidebar w # And I should see a browse distributors button page.should have_selector "#distributor_filter input[value='Browse All Distributors']" end +=end scenario "viewing a list of all distributors" do # Given some distributors diff --git a/spec/features/consumer/suppliers_spec.rb b/spec/features/consumer/suppliers_spec.rb index c48cae9d13..f960a6e444 100644 --- a/spec/features/consumer/suppliers_spec.rb +++ b/spec/features/consumer/suppliers_spec.rb @@ -21,6 +21,9 @@ feature %q{ create(:product, :supplier => s1) create(:product, :supplier => s3, :on_hand => 0) + # And no limit set for the sidebar + sidebar_suppliers_limit = false + # When I go to the home page visit spree.root_path @@ -29,13 +32,15 @@ feature %q{ page.should_not have_selector 'a', :text => s2.name #has no products page.should_not have_selector 'a', :text => s3.name #has no products on hand - # And I shouldn't see 'xx more' - page.should_not have_selector '#supplier_filter span.filter_more' + # And I should see '5 more' + suppliers_more = Enterprise.is_primary_producer.distinct_count - Enterprise.is_primary_producer.with_supplied_active_products_on_hand.limit(sidebar_suppliers_limit).length + page.should have_selector '#supplier_filter span.filter_more', :text => "#{suppliers_more} more" - # And I shouldn't see a browse suppliers button + # And I should (always) see a browse suppliers button page.should have_selector "#supplier_filter input[value='Browse All Suppliers']" end +=begin scenario "viewing a list of suppliers (with active products) in the sidebar when there's more than 5" do # Given some suppliers s1 = create(:supplier_enterprise) @@ -65,6 +70,7 @@ feature %q{ # And I should see a browse suppliers button page.should have_selector "#supplier_filter input[value='Browse All Suppliers']" end +=end scenario "viewing a list of all suppliers" do # Given some suppliers