Add view all suppliers page

This commit is contained in:
Rohan Mitchell
2012-10-17 07:50:58 +11:00
parent d09123eb22
commit 36d342f216
4 changed files with 36 additions and 1 deletions

View File

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

View File

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

View File

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

View File

@@ -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 => "<p>Hello, world!</p>")