test for inactive enterprises being counted in 'x more' on sidebar, disable limit test

This commit is contained in:
David Cook
2013-07-22 14:55:46 +10:00
parent 66d345d360
commit 55277e2f0a
2 changed files with 19 additions and 7 deletions

View File

@@ -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

View File

@@ -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