mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Add view all suppliers page
This commit is contained in:
@@ -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 })
|
||||
|
||||
@@ -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
|
||||
|
||||
10
app/views/spree/suppliers/index.html.haml
Normal file
10
app/views/spree/suppliers/index.html.haml
Normal 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
|
||||
@@ -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>")
|
||||
|
||||
Reference in New Issue
Block a user