Compare commits

...

6 Commits
0.2.1 ... 0.2.4

Author SHA1 Message Date
Rohan Mitchell
11483a77e8 Update bugsnag and spree_paypal_express for paypal error debugging 2012-10-17 08:42:33 +11:00
Rohan Mitchell
ba895ed486 Display CMS content for suppliers page 2012-10-17 07:54:12 +11:00
Rohan Mitchell
36d342f216 Add view all suppliers page 2012-10-17 07:50:58 +11:00
Rohan Mitchell
d09123eb22 Do not show suppliers with no products in stock 2012-10-17 07:36:18 +11:00
Rohan Mitchell
642f58551c Use spree_paypal_express from RohanM with debugging for nil state from paypal address error 2012-10-16 10:34:11 +11:00
Rohan Mitchell
9fbcd8c01b Display CMS pages with Spree's layout 2012-10-12 10:21:21 +11:00
10 changed files with 108 additions and 44 deletions

View File

@@ -6,7 +6,7 @@ gem 'rails', '3.2.8'
gem 'pg'
gem 'spree', :git => 'git://github.com/spree/spree.git', :branch => '1-1-stable'
gem 'spree_i18n', :git => 'git://github.com/spree/spree_i18n.git'
gem 'spree_paypal_express', :git => 'git://github.com/spree/spree_paypal_express.git', :branch => '1-1-stable'
gem 'spree_paypal_express', :git => 'git://github.com/RohanM/spree_paypal_express.git', :branch => '1-1-stable'
gem 'spree_last_address', :git => 'git://github.com/dancinglightning/spree-last-address.git'
gem 'comfortable_mexican_sofa'

View File

@@ -6,6 +6,15 @@ GIT
actionpack (~> 3.0)
activemodel (~> 3.0)
GIT
remote: git://github.com/RohanM/spree_paypal_express.git
revision: ab580fde06d6b2b607db74a7eb4e5ef52a313862
branch: 1-1-stable
specs:
spree_paypal_express (1.1.0)
spree_auth (>= 1.0.0)
spree_core (>= 1.0.0)
GIT
remote: git://github.com/dancinglightning/spree-last-address.git
revision: f5ed71a5482fbc16da559737903bb46fe032c150
@@ -77,15 +86,6 @@ GIT
i18n (~> 0.5)
spree (~> 1.1)
GIT
remote: git://github.com/spree/spree_paypal_express.git
revision: 2c61f1700ef853e3d4f39739793dc3308422e94b
branch: 1-1-stable
specs:
spree_paypal_express (1.1.0)
spree_auth (>= 1.0.0)
spree_core (>= 1.0.0)
GEM
remote: http://rubygems.org/
specs:
@@ -144,10 +144,10 @@ GEM
nokogiri (>= 1.4.4)
uuidtools (~> 2.1)
bcrypt-ruby (3.0.1)
bugsnag (1.1.2)
httparty (~> 0.8.3)
multi_json (~> 1.3.4)
builder (3.0.3)
bugsnag (1.2.4)
httparty (>= 0.5, < 1.0)
multi_json (~> 1.0)
builder (3.0.4)
cancan (1.6.7)
capybara (1.1.2)
mime-types (>= 1.16)
@@ -158,7 +158,7 @@ GEM
xpath (~> 0.1.4)
childprocess (0.3.2)
ffi (~> 1.0.6)
cocaine (0.3.0)
cocaine (0.4.0)
coderay (1.0.7)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
@@ -209,7 +209,7 @@ GEM
multi_xml
i18n (0.6.1)
journey (1.0.4)
jquery-rails (2.1.2)
jquery-rails (2.1.3)
railties (>= 3.1.0, < 5.0)
thor (~> 0.14)
json (1.7.5)
@@ -237,7 +237,7 @@ GEM
railties (>= 3.0.0)
nokogiri (1.5.5)
orm_adapter (0.0.7)
paperclip (2.7.0)
paperclip (2.8.0)
activerecord (>= 2.3.0)
activesupport (>= 2.3.2)
cocaine (>= 0.0.2)
@@ -261,7 +261,7 @@ GEM
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.8)
actionmailer (= 3.2.8)
@@ -325,7 +325,7 @@ GEM
libv8 (~> 3.3.10)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.10)
treetop (1.4.11)
polyglot
polyglot (>= 0.3.1)
truncate_html (0.5.5)

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

@@ -12,6 +12,17 @@ module Spree
after_initialize :initialize_country
before_validation :set_unused_address_fields
def has_products_on_hand?
self.products.where('count_on_hand > 0').present?
end
def to_param
"#{id}-#{name.parameterize}"
end
private
def initialize_country
self.address ||= Address.new
self.address.country = Country.find_by_id(Spree::Config[:default_country_id]) if self.address.new_record?
@@ -21,8 +32,5 @@ module Spree
address.firstname = address.lastname = address.phone = 'unused' if address.present?
end
def to_param
"#{id}-#{name.parameterize}"
end
end
end

View File

@@ -1,14 +1 @@
<!DOCTYPE html>
<html>
<head>
<title>Openfoodweb</title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>
<%= render :file => 'spree/layouts/spree_application' %>

View File

@@ -2,7 +2,9 @@
%h6.filter_name Shop by Supplier
%ul.filter_choices
- @suppliers.each do |supplier|
%li.nowrap= link_to supplier.name, 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,12 @@
- content_for :sidebar do
%div{'data-hook' => "homepage_sidebar_navigation"}
= render 'spree/sidebar'
%h1 Suppliers
= cms_page_content(:content, Cms::Page.find_by_full_path('/suppliers'))
%ul.suppliers
- @suppliers.each do |supplier|
%li= link_to supplier.name, supplier

View File

@@ -118,3 +118,10 @@ ComfortableMexicanSofa::HttpAuth.password = 'password'
# ComfortableMexicanSofa::ViewHooks.add(:html_head, '/layouts/admin/html_head')
# ComfortableMexicanSofa::ViewHooks.add(:page_form, '/layouts/admin/page_form')
ComfortableMexicanSofa::ViewHooks.add(:navigation, 'layouts/cms_nav_spree')
# Provide some Spree helpers to the CMS controller so it can render Spree's layout
ComfortableMexicanSofa::CmsContentController.class_eval do
helper 'spree/base'
include Spree::Core::ControllerHelpers
include Spree::Core::Engine.routes.url_helpers
end

View File

@@ -8,14 +8,32 @@ module Spree
it { should belong_to(:address) }
end
it "should default country to system country" do
supplier = Supplier.new
supplier.address.country.should == Country.find_by_id(Config[:default_country_id])
end
describe "validations" do
it { should validate_presence_of(:name) }
end
it "should default country to system country" do
subject.address.country.should == Country.find_by_id(Config[:default_country_id])
end
context "has_products_on_hand?" do
before :each do
@supplier = create(:supplier)
end
it "returns false when no products" do
@supplier.should_not have_products_on_hand
end
it "returns false when the product is out of stock" do
create(:product, :supplier => @supplier, :on_hand => 0)
@supplier.should_not have_products_on_hand
end
it "returns true when the product is in stock" do
create(:product, :supplier => @supplier, :on_hand => 1)
@supplier.should have_products_on_hand
end
end
end
end

View File

@@ -8,17 +8,43 @@ 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)
s3 = create(:supplier)
# And some of those suppliers have a product
create(:product, :supplier => s1)
create(:product, :supplier => s3)
# When I go to the home page
visit spree.root_path
# Then I should see a list containing all the suppliers that have products in stock
page.should have_selector 'a', :text => s1.name
page.should have_selector 'a', :text => s3.name
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
[s1, s2, s3].each { |s| page.should have_selector 'a', :text => s.name }
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