Add test for filtering by distributor

This commit is contained in:
Rohan Mitchell
2012-06-20 15:19:26 +10:00
parent 9adfe58086
commit a445216e6c
2 changed files with 17 additions and 2 deletions

View File

@@ -10,7 +10,7 @@
<% labels.each do |nm,val| %>
<li class="nowrap">
<% active = params[:search][filter[:scope]] && params[:search][filter[:scope]].include?(val.to_s) %>
<%= link_to nm, "?search[#{filter[:scope].to_s}][]=#{val}" %>
<%= link_to nm, "?search[#{filter[:scope].to_s}][]=#{CGI.escape(val)}" %>
</li>
<% end %>
</ul>

View File

@@ -23,6 +23,21 @@ feature %q{
end
end
scenario "browsing products by distributor"
scenario "browsing products by distributor" do
# Given a product at each of two distributors
d1 = create(:distributor)
d2 = create(:distributor)
p1 = create(:product, :distributors => [d1])
p2 = create(:product, :distributors => [d2])
# When I go to the home page, I should see both products
visit spree.root_path
page.should have_content p1.name
page.should have_content p2.name
# When I filter by one distributor, I should see only the product from that distributor
click_link d1.name
page.should have_content p1.name
page.should_not have_content p2.name
end
end