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