diff --git a/app/controllers/spree/suppliers_controller.rb b/app/controllers/spree/suppliers_controller.rb index 9ec5c0625b..57c82cdf6d 100644 --- a/app/controllers/spree/suppliers_controller.rb +++ b/app/controllers/spree/suppliers_controller.rb @@ -2,6 +2,10 @@ module Spree class SuppliersController < BaseController helper 'spree/products' + def index + @suppliers = Supplier.all + end + def show options = {:supplier_id => params[:id]} options.merge(params.reject { |k,v| k == :id }) diff --git a/app/views/spree/products/_source_sidebar.html.haml b/app/views/spree/products/_source_sidebar.html.haml index ee4e43c526..f4ce33d3ea 100644 --- a/app/views/spree/products/_source_sidebar.html.haml +++ b/app/views/spree/products/_source_sidebar.html.haml @@ -4,6 +4,7 @@ - @suppliers.each do |supplier| - if supplier.has_products_on_hand? %li.nowrap= link_to supplier.name, supplier + = button_to 'Browse All Suppliers', suppliers_path, :method => :get %h6.filter_name Shop by Distributor %ul.filter_choices diff --git a/app/views/spree/suppliers/index.html.haml b/app/views/spree/suppliers/index.html.haml new file mode 100644 index 0000000000..d63a9a2b63 --- /dev/null +++ b/app/views/spree/suppliers/index.html.haml @@ -0,0 +1,10 @@ +- content_for :sidebar do + %div{'data-hook' => "homepage_sidebar_navigation"} + = render 'spree/sidebar' + + +%h1 Suppliers + +%ul.suppliers + - @suppliers.each do |supplier| + %li= link_to supplier.name, supplier diff --git a/spec/requests/consumer/suppliers_spec.rb b/spec/requests/consumer/suppliers_spec.rb index 46f5da25a3..1c88ffd64f 100644 --- a/spec/requests/consumer/suppliers_spec.rb +++ b/spec/requests/consumer/suppliers_spec.rb @@ -8,7 +8,7 @@ feature %q{ include AuthenticationWorkflow include WebHelper - scenario "viewing a list of suppliers" do + scenario "viewing a list of suppliers in the sidebar" do # Given some suppliers s1 = create(:supplier) s2 = create(:supplier) @@ -27,6 +27,26 @@ feature %q{ page.should_not have_selector 'a', :text => s2.name end + scenario "viewing a list of all suppliers" do + # Given some suppliers + s1 = create(:supplier) + s2 = create(:supplier) + s3 = create(:supplier) + + # And some of those suppliers have a product + create(:product, :supplier => s1) + create(:product, :supplier => s3) + + # When I go to the suppliers listing page + visit spree.root_path + click_button 'Browse All Suppliers' + + # Then I should see a list containing all the suppliers + page.should have_selector '#content a', :text => s1.name + page.should have_selector '#content a', :text => s2.name + page.should have_selector '#content a', :text => s3.name + end + scenario "viewing products provided by a supplier" do # Given a supplier with a product s = create(:supplier, :name => 'Murrnong', :long_description => "

Hello, world!

")