From a445216e6c3b441e3640e183a4a5545a8977eb9e Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 20 Jun 2012 15:19:26 +1000 Subject: [PATCH] Add test for filtering by distributor --- app/views/spree/shared/_filters.html.erb | 2 +- spec/requests/consumer/distributors_spec.rb | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/views/spree/shared/_filters.html.erb b/app/views/spree/shared/_filters.html.erb index cbb70ba94a..fa1f3d7af7 100644 --- a/app/views/spree/shared/_filters.html.erb +++ b/app/views/spree/shared/_filters.html.erb @@ -10,7 +10,7 @@ <% labels.each do |nm,val| %>
  • <% 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)}" %>
  • <% end %> diff --git a/spec/requests/consumer/distributors_spec.rb b/spec/requests/consumer/distributors_spec.rb index 32ba524488..12d935541f 100644 --- a/spec/requests/consumer/distributors_spec.rb +++ b/spec/requests/consumer/distributors_spec.rb @@ -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