Fix error on supplier page, add test to cover

This commit is contained in:
Rohan Mitchell
2012-09-19 15:46:56 +10:00
parent f1f9b5b2e8
commit 3894ce946d
2 changed files with 38 additions and 0 deletions

View File

@@ -1,5 +1,7 @@
module Spree
class SuppliersController < BaseController
helper 'spree/products'
def show
options = {:supplier_id => params[:id]}
options.merge(params.reject { |k,v| k == :id })

View File

@@ -0,0 +1,36 @@
require 'spec_helper'
feature %q{
As a consumer
I want to see a list of products from a supplier
So that I can connect with them (and maybe buy stuff too)
} do
include AuthenticationWorkflow
include WebHelper
scenario "viewing a list of suppliers" do
# Given some suppliers
s1 = create(:supplier)
s2 = create(:supplier)
s3 = create(:supplier)
# When I go to the home page
visit spree.root_path
# Then I should see a list containing all the suppliers
[s1, s2, s3].each { |s| page.should have_selector 'a', :text => s.name }
end
scenario "viewing products provided by a supplier" do
# Given a supplier with a product
s = create(:supplier, :name => 'Murrnong')
p = create(:product, :supplier => s)
# When I select the supplier
visit spree.root_path
click_link s.name
# Then I should see the product
page.should have_content p.name
end
end