diff --git a/app/models/spree/product_decorator.rb b/app/models/spree/product_decorator.rb index 635430d163..5156e30d7f 100644 --- a/app/models/spree/product_decorator.rb +++ b/app/models/spree/product_decorator.rb @@ -1,5 +1,3 @@ Spree::Product.class_eval do - attr_accessible :supplier_id - belongs_to :supplier end \ No newline at end of file diff --git a/app/overrides/add_supplier_to_product.rb b/app/overrides/add_supplier_to_product.rb new file mode 100644 index 0000000000..1607872d6d --- /dev/null +++ b/app/overrides/add_supplier_to_product.rb @@ -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") \ No newline at end of file diff --git a/app/views/spree/admin/products/_supplier.html.haml b/app/views/spree/admin/products/_supplier.html.haml new file mode 100644 index 0000000000..0c0ae1df52 --- /dev/null +++ b/app/views/spree/admin/products/_supplier.html.haml @@ -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 \ No newline at end of file diff --git a/spec/request/product_spec.rb b/spec/request/product_spec.rb new file mode 100644 index 0000000000..4215bac66f --- /dev/null +++ b/spec/request/product_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e66d9802c1..2f96c1f12d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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 diff --git a/spec/support/spree/url_helpers.rb b/spec/support/spree/url_helpers.rb new file mode 100644 index 0000000000..c14c659fe9 --- /dev/null +++ b/spec/support/spree/url_helpers.rb @@ -0,0 +1,7 @@ +module Spree + module UrlHelpers + def spree + Spree::Core::Engine.routes.url_helpers + end + end +end \ No newline at end of file