add supplier to product on admin views.

This commit is contained in:
Andrew Spinks
2012-04-29 18:35:14 +10:00
parent 3b2ae5bca1
commit 5088363c84
6 changed files with 60 additions and 2 deletions

View File

@@ -1,5 +1,3 @@
Spree::Product.class_eval do
attr_accessible :supplier_id
belongs_to :supplier
end

View File

@@ -0,0 +1,9 @@
Deface::Override.new(:virtual_path => "spree/admin/products/_form",
:insert_top => "[data-hook='admin_product_form_right']",
:partial => "spree/admin/products/supplier",
:name => "supplier")
Deface::Override.new(:virtual_path => "spree/admin/products/new",
:insert_bottom => ".left",
:partial => "spree/admin/products/supplier",
:name => "supplier")

View File

@@ -0,0 +1,5 @@
= f.field_container :supplier do
= f.label :supplier
%br
= f.collection_select(:supplier_id, Spree::Supplier.all, :id, :name, :include_blank => true)
= f.error_message_on :supplier

View File

@@ -0,0 +1,36 @@
require "spec_helper"
feature %q{
As a supplier
I want to myself as the supplier of a product
} do
# include AuthenticationWorkflow
# include WebHelper
background do
# @booking = Booking.make_booking
# @product_manager = User.make(:product_manager)
end
context "Given I am editing a booking" do
scenario "I should be able to add a new note", :js =>true do
# user = Factory(:admin_user, :email => "c@example.com")
# sign_in_as!(user)
visit spree.admin_path
click_link 'New Product'
# page.should have_content 'Notes'
# fill_in 'booking_note_comment', :with => 'A new note !!!'
# click_button 'Add note'
# #flash_message.should == 'Booking Note successfully created.'
# within('.notes-list') do
# page.should have_content('A new note !!!')
# page.should have_content(@product_manager.name)
# end
# click_link 'Back to Dashboard'
# page.should have_content 'Booking details'
end
end
end

View File

@@ -3,6 +3,7 @@ ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
@@ -29,4 +30,6 @@ RSpec.configure do |config|
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
config.include Spree::UrlHelpers
end

View File

@@ -0,0 +1,7 @@
module Spree
module UrlHelpers
def spree
Spree::Core::Engine.routes.url_helpers
end
end
end