From 34588e6141fcbeda949c8461e151ae3217a17dd4 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 1 Nov 2012 09:55:45 +1100 Subject: [PATCH] Remove old supplier and distributor routes, models, controllers, views, specs --- .../admin/distributors_controller.rb | 28 ------- app/controllers/admin/suppliers_controller.rb | 16 ---- app/controllers/distributors_controller.rb | 35 -------- app/controllers/suppliers_controller.rb | 15 ---- app/models/distributor.rb | 31 ------- app/models/supplier.rb | 33 -------- app/overrides/distributors_admin_tab.rb | 11 --- app/views/admin/distributors/_form.html.haml | 42 ---------- app/views/admin/distributors/edit.html.erb | 6 -- app/views/admin/distributors/index.html.erb | 40 ---------- app/views/admin/distributors/new.html.erb | 7 -- app/views/admin/distributors/show.html.haml | 42 ---------- app/views/admin/suppliers/_form.html.haml | 24 ------ app/views/admin/suppliers/edit.html.haml | 5 -- app/views/admin/suppliers/index.html.haml | 22 ----- app/views/admin/suppliers/new.html.haml | 5 -- app/views/admin/suppliers/show.html.haml | 27 ------- app/views/distributors/show.html.haml | 7 -- app/views/suppliers/index.html.haml | 12 --- app/views/suppliers/show.html.haml | 7 -- config/routes.rb | 15 ---- ...22403_remove_suppliers_and_distributors.rb | 37 +++++++++ db/schema.rb | 31 +------ .../distributors_controller_spec.rb | 75 ----------------- spec/factories.rb | 21 ----- spec/requests/admin/distributors_spec.rb | 80 ------------------- spec/requests/admin/suppliers_spec.rb | 56 ------------- 27 files changed, 38 insertions(+), 692 deletions(-) delete mode 100644 app/controllers/admin/distributors_controller.rb delete mode 100644 app/controllers/admin/suppliers_controller.rb delete mode 100644 app/controllers/distributors_controller.rb delete mode 100644 app/controllers/suppliers_controller.rb delete mode 100644 app/models/distributor.rb delete mode 100644 app/models/supplier.rb delete mode 100644 app/overrides/distributors_admin_tab.rb delete mode 100644 app/views/admin/distributors/_form.html.haml delete mode 100644 app/views/admin/distributors/edit.html.erb delete mode 100644 app/views/admin/distributors/index.html.erb delete mode 100644 app/views/admin/distributors/new.html.erb delete mode 100644 app/views/admin/distributors/show.html.haml delete mode 100644 app/views/admin/suppliers/_form.html.haml delete mode 100644 app/views/admin/suppliers/edit.html.haml delete mode 100644 app/views/admin/suppliers/index.html.haml delete mode 100644 app/views/admin/suppliers/new.html.haml delete mode 100644 app/views/admin/suppliers/show.html.haml delete mode 100644 app/views/distributors/show.html.haml delete mode 100644 app/views/suppliers/index.html.haml delete mode 100644 app/views/suppliers/show.html.haml create mode 100644 db/migrate/20121031222403_remove_suppliers_and_distributors.rb delete mode 100644 spec/controllers/distributors_controller_spec.rb delete mode 100644 spec/requests/admin/distributors_spec.rb delete mode 100644 spec/requests/admin/suppliers_spec.rb diff --git a/app/controllers/admin/distributors_controller.rb b/app/controllers/admin/distributors_controller.rb deleted file mode 100644 index 21d561a1ea..0000000000 --- a/app/controllers/admin/distributors_controller.rb +++ /dev/null @@ -1,28 +0,0 @@ -module Admin - class DistributorsController < ResourceController - before_filter :load_distributor_set, :only => :index - before_filter :load_countries, :except => :index - - def bulk_update - @distributor_set = DistributorSet.new(params[:distributor_set]) - if @distributor_set.save - redirect_to main_app.admin_distributors_path, :notice => 'Distributor collection times updated.' - else - render :index - end - end - - private - def load_distributor_set - @distributor_set = DistributorSet.new :distributors => collection - end - - def load_countries - @countries = Spree::Country.order(:name) - end - - def collection - super.order(:name) - end - end -end diff --git a/app/controllers/admin/suppliers_controller.rb b/app/controllers/admin/suppliers_controller.rb deleted file mode 100644 index 63eb594bf3..0000000000 --- a/app/controllers/admin/suppliers_controller.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Admin - class SuppliersController < ResourceController - before_filter :load_data, :except => [:index] - - helper 'spree/products' - - private - def load_data - @countries = Spree::Country.order(:name) - end - - def collection - super.order(:name) - end - end -end diff --git a/app/controllers/distributors_controller.rb b/app/controllers/distributors_controller.rb deleted file mode 100644 index 97c6d81691..0000000000 --- a/app/controllers/distributors_controller.rb +++ /dev/null @@ -1,35 +0,0 @@ -class DistributorsController < BaseController - def show - options = {:distributor_id => params[:id]} - options.merge(params.reject { |k,v| k == :id }) - - @distributor = Distributor.find params[:id] - - @searcher = Spree::Config.searcher_class.new(options) - @products = @searcher.retrieve_products - end - - def select - distributor = Distributor.find params[:id] - - order = current_order(true) - - if order.can_change_distributor? - order.distributor = distributor - order.save! - end - - redirect_to distributor - end - - def deselect - order = current_order(true) - - if order.can_change_distributor? - order.distributor = nil - order.save! - end - - redirect_to root_path - end -end diff --git a/app/controllers/suppliers_controller.rb b/app/controllers/suppliers_controller.rb deleted file mode 100644 index 3b76225449..0000000000 --- a/app/controllers/suppliers_controller.rb +++ /dev/null @@ -1,15 +0,0 @@ -class SuppliersController < BaseController - def index - @suppliers = Supplier.all - end - - def show - options = {:supplier_id => params[:id]} - options.merge(params.reject { |k,v| k == :id }) - - @supplier = Supplier.find params[:id] - - @searcher = Spree::Config.searcher_class.new(options) - @products = @searcher.retrieve_products - end -end diff --git a/app/models/distributor.rb b/app/models/distributor.rb deleted file mode 100644 index 1bc2d274c5..0000000000 --- a/app/models/distributor.rb +++ /dev/null @@ -1,31 +0,0 @@ -class Distributor < ActiveRecord::Base - belongs_to :pickup_address, :foreign_key => 'pickup_address_id', :class_name => 'Spree::Address' - has_many :orders, :class_name => 'Spree::Order' - - has_many :product_distributions, :dependent => :destroy - has_many :products, :through => :product_distributions - - accepts_nested_attributes_for :pickup_address - - validates_presence_of :name, :pickup_address - validates_associated :pickup_address - - scope :by_name, order('name') - scope :with_active_products_on_hand, lambda { joins(:products).where('spree_products.deleted_at IS NULL AND spree_products.available_on <= ? AND spree_products.count_on_hand > 0', Time.now).select('distinct(distributors.*)') } - - after_initialize :initialize_country - before_validation :set_unused_address_fields - - def initialize_country - self.pickup_address ||= Spree::Address.new - self.pickup_address.country = Spree::Country.find_by_id(Spree::Config[:default_country_id]) if self.pickup_address.new_record? - end - - def set_unused_address_fields - pickup_address.firstname = pickup_address.lastname = pickup_address.phone = 'unused' if pickup_address.present? - end - - def to_param - "#{id}-#{name.parameterize}" - end -end diff --git a/app/models/supplier.rb b/app/models/supplier.rb deleted file mode 100644 index 76518a5f34..0000000000 --- a/app/models/supplier.rb +++ /dev/null @@ -1,33 +0,0 @@ -class Supplier < ActiveRecord::Base - has_many :products, :class_name => 'Spree::Product' - belongs_to :address, :class_name => 'Spree::Address' - - accepts_nested_attributes_for :address - - validates_presence_of :name, :address - validates_associated :address - - 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 ||= Spree::Address.new - self.address.country = Spree::Country.find_by_id(Spree::Config[:default_country_id]) if self.address.new_record? - end - - def set_unused_address_fields - address.firstname = address.lastname = address.phone = 'unused' if address.present? - end - -end diff --git a/app/overrides/distributors_admin_tab.rb b/app/overrides/distributors_admin_tab.rb deleted file mode 100644 index b0b71bfcea..0000000000 --- a/app/overrides/distributors_admin_tab.rb +++ /dev/null @@ -1,11 +0,0 @@ -Deface::Override.new(:virtual_path => "spree/layouts/admin", - :name => "distributors_admin_tabs", - :insert_bottom => "[data-hook='admin_tabs'], #admin_tabs[data-hook]", - :text => "<%= tab(:distributors, :url => main_app.admin_distributors_path) %>", - :disabled => false) - -Deface::Override.new(:virtual_path => "spree/layouts/admin", - :name => "suppliers_admin_tabs", - :insert_bottom => "[data-hook='admin_tabs'], #admin_tabs[data-hook]", - :text => "<%= tab(:suppliers, :url => main_app.admin_suppliers_path) %>", - :disabled => false) diff --git a/app/views/admin/distributors/_form.html.haml b/app/views/admin/distributors/_form.html.haml deleted file mode 100644 index efc0dd37f0..0000000000 --- a/app/views/admin/distributors/_form.html.haml +++ /dev/null @@ -1,42 +0,0 @@ -- content_for :head do - = render 'shared/cms_elrte_head' - -%table{"data-hook" => "distributors"} - %tr{"data-hook" => "name"} - %td Name: - %td= f.text_field :name - %tr{"data-hook" => "description"} - %td Description: - %td= f.text_field :description - %tr{'data-hook' => "long_description"} - %td Extended Description: - %td= f.text_area :long_description, :class => 'rich_text' - %tr{"data-hook" => "contact"} - %td Contact: - %td= f.text_field :contact - %tr{"data-hook" => "phone"} - %td Phone: - %td= f.text_field :phone - %tr{"data-hook" => "email"} - %td Email: - %td= f.text_field :email - %tr{"data-hook" => "url"} - %td URL: - %td= f.text_field :url - %tr{"data-hook" => "abn"} - %td ABN: - %td= f.text_field :abn - %tr{"data-hook" => "acn"} - %td ACN: - %td= f.text_field :acn -%fieldset - %legend Pickup details - %table{"data-hook" => "distributors_pickup_details"} - %tr{"data-hook" => "next_collection_at"} - %td Next collection date/time: - %td= f.text_field :next_collection_at - %tr{"data-hook" => "pickup_times"} - %td Regular pickup times: - %td= f.text_field :pickup_times - = f.fields_for :pickup_address do |pickup_address_form| - = render 'spree/admin/shared/address_form', :f => pickup_address_form diff --git a/app/views/admin/distributors/edit.html.erb b/app/views/admin/distributors/edit.html.erb deleted file mode 100644 index a67c215206..0000000000 --- a/app/views/admin/distributors/edit.html.erb +++ /dev/null @@ -1,6 +0,0 @@ - -<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @distributor } %> -<%= form_for [:admin, @distributor] do |f| %> - <%= render :partial => 'form', :locals => { :f => f } %> - <%= render :partial => 'spree/admin/shared/edit_resource_links' %> -<% end %> \ No newline at end of file diff --git a/app/views/admin/distributors/index.html.erb b/app/views/admin/distributors/index.html.erb deleted file mode 100644 index 86eef01337..0000000000 --- a/app/views/admin/distributors/index.html.erb +++ /dev/null @@ -1,40 +0,0 @@ -
- -
-
- -<%= form_for @distributor_set, :url => main_app.bulk_update_admin_distributors_path do |f| %> - - - - - - - - - - - <%= f.fields_for :distributors do |distributor_form| %> - <% distributor = distributor_form.object %> - - - - - - - <% end %> - <% if @distributors.empty? %> - - <% end %> - -
NameNext Collection Date/TimeDescription
<%= link_to distributor.name, main_app.admin_distributor_path(distributor) %><%= distributor_form.text_field :next_collection_at %><%= distributor.description %> - <%= link_to_edit distributor, :class => 'edit' %>   - <%= link_to_delete distributor %> -
<%= t(:none) %>
- - <%= f.submit 'Update' %> -<% end %> diff --git a/app/views/admin/distributors/new.html.erb b/app/views/admin/distributors/new.html.erb deleted file mode 100644 index df6b32cbbe..0000000000 --- a/app/views/admin/distributors/new.html.erb +++ /dev/null @@ -1,7 +0,0 @@ - -<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @distributor } %> - -<%= form_for [main_app, :admin, @distributor] do |f| %> - <%= render :partial => 'form', :locals => { :f => f } %> - <%= render :partial => 'spree/admin/shared/new_resource_links' %> -<% end %> diff --git a/app/views/admin/distributors/show.html.haml b/app/views/admin/distributors/show.html.haml deleted file mode 100644 index 1f1357457a..0000000000 --- a/app/views/admin/distributors/show.html.haml +++ /dev/null @@ -1,42 +0,0 @@ -%h1 Distributor -%table - %tr - %th Name: - %td= @distributor.name - %tr - %th Description: - %td= @distributor.description - %tr - %th Extended Description: - %td= @distributor.long_description.andand.html_safe - %tr - %th Contact person: - %td= @distributor.contact - %tr - %th Phone number: - %td= @distributor.phone - %tr - %th Email: - %td= @distributor.email - %tr - %th Pickup address: - %td= render 'spree/shared/address', :address => @distributor.pickup_address - %tr - %th Next collection date/time: - %td= @distributor.next_collection_at - %tr - %th Regular pickup times: - %td= @distributor.pickup_times - %tr - %th ABN: - %td= @distributor.abn - %tr - %th ACN: - %td= @distributor.acn - %tr - %th URL: - %td= @distributor.url -%p - = link_to :Edit, main_app.edit_admin_distributor_path(@distributor), :class => 'edit_distributor' - = t(:or) - = link_to t(:back), main_app.admin_distributors_path diff --git a/app/views/admin/suppliers/_form.html.haml b/app/views/admin/suppliers/_form.html.haml deleted file mode 100644 index 2e145f44d0..0000000000 --- a/app/views/admin/suppliers/_form.html.haml +++ /dev/null @@ -1,24 +0,0 @@ -- content_for :head do - = render 'shared/cms_elrte_head' - -%table{'data-hook' => "suppliers"} - %tr{'data-hook' => "name"} - %td Name: - %td= f.text_field :name - %tr{'data-hook' => "description"} - %td Description: - %td= f.text_field :description - %tr{'data-hook' => "long_description"} - %td Extended Description: - %td= f.text_area :long_description, :class => 'rich_text' - = f.fields_for :address do |address_form| - = render 'spree/admin/shared/address_form', :f => address_form - %tr{'data-hook' => "email"} - %td Email: - %td= f.text_field :email - %tr{'data-hook' => "website"} - %td Website: - %td= f.text_field :website - %tr{'data-hook' => "twitter"} - %td Twitter: - %td= f.text_field :twitter diff --git a/app/views/admin/suppliers/edit.html.haml b/app/views/admin/suppliers/edit.html.haml deleted file mode 100644 index b51781dede..0000000000 --- a/app/views/admin/suppliers/edit.html.haml +++ /dev/null @@ -1,5 +0,0 @@ - -= render :partial => 'spree/shared/error_messages', :locals => { :target => @supplier } -= form_for [:admin, @supplier] do |f| - = render :partial => 'form', :locals => { :f => f } - = render :partial => 'spree/admin/shared/edit_resource_links' diff --git a/app/views/admin/suppliers/index.html.haml b/app/views/admin/suppliers/index.html.haml deleted file mode 100644 index 8eb54a6d8d..0000000000 --- a/app/views/admin/suppliers/index.html.haml +++ /dev/null @@ -1,22 +0,0 @@ -.toolbar{'data-hook' => "suppliers"} - %ul.actions - %li= button_link_to "New Supplier", main_app.new_admin_supplier_path, :icon => 'add', :id => 'admin_new_supplier_link' - %br.clear -%table#listing_suppliers.index - %thead - %tr{'data-hook' => "suppliers_header"} - %th Name - %th Description - %th - %tbody - - @suppliers.each do |supplier| - %tr - %td= link_to supplier.name, main_app.admin_supplier_path(supplier) - %td= supplier.description - %td{'data-hook' => "admin_supplier_index_row_actions"} - = link_to_edit supplier, :class => 'edit' -   - = link_to_delete supplier - - if @suppliers.empty? - %tr - %td{:colspan => "2"}= t(:none) diff --git a/app/views/admin/suppliers/new.html.haml b/app/views/admin/suppliers/new.html.haml deleted file mode 100644 index cbdf66570a..0000000000 --- a/app/views/admin/suppliers/new.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -= render :partial => 'spree/shared/error_messages', :locals => { :target => @supplier } - -= form_for [main_app, :admin, @supplier] do |f| - = render :partial => 'form', :locals => { :f => f } - = render :partial => 'spree/admin/shared/new_resource_links' diff --git a/app/views/admin/suppliers/show.html.haml b/app/views/admin/suppliers/show.html.haml deleted file mode 100644 index c6ac3b8e24..0000000000 --- a/app/views/admin/suppliers/show.html.haml +++ /dev/null @@ -1,27 +0,0 @@ -%h1 Supplier -%table - %tr - %th Name: - %td= @supplier.name - %tr - %th Description: - %td= @supplier.description - %tr - %th Extended Description: - %td= @supplier.long_description.andand.html_safe - %tr - %th Address: - %td= render 'spree/shared/address', :address => @supplier.address - %tr - %th Email: - %td= @supplier.email - %tr - %th Website: - %td= @supplier.website - %tr - %th Twitter: - %td= @supplier.twitter -%p - = link_to :Edit, main_app.edit_admin_supplier_path(@supplier), :class => 'edit_supplier' - = t(:or) - = link_to t(:back), main_app.admin_suppliers_path diff --git a/app/views/distributors/show.html.haml b/app/views/distributors/show.html.haml deleted file mode 100644 index da898156e1..0000000000 --- a/app/views/distributors/show.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -%h2= @distributor.name - -.distributor-description= @distributor.long_description.andand.html_safe - -%h3 Available Now - -= render :template => 'spree/products/index' diff --git a/app/views/suppliers/index.html.haml b/app/views/suppliers/index.html.haml deleted file mode 100644 index 04bd95375c..0000000000 --- a/app/views/suppliers/index.html.haml +++ /dev/null @@ -1,12 +0,0 @@ -- 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 diff --git a/app/views/suppliers/show.html.haml b/app/views/suppliers/show.html.haml deleted file mode 100644 index 9605d5db1a..0000000000 --- a/app/views/suppliers/show.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -%h2= @supplier.name - -.supplier-description= @supplier.long_description.andand.html_safe - -%h3 Available Now - -= render :template => 'spree/products/index' diff --git a/config/routes.rb b/config/routes.rb index 67bd610c69..1a018ba3ae 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,25 +7,10 @@ Openfoodweb::Application.routes.draw do get :deselect_distributor, :on => :collection end - # Deprecated - resources :suppliers - # Deprecated - resources :distributors do - get :select, :on => :member - get :deselect, :on => :collection - end - namespace :admin do resources :enterprises do post :bulk_update, :on => :collection, :as => :bulk_update end - - # Deprecated - resources :distributors do - post :bulk_update, :on => :collection, :as => :bulk_update - end - # Deprecated - resources :suppliers end # Mount Spree's routes diff --git a/db/migrate/20121031222403_remove_suppliers_and_distributors.rb b/db/migrate/20121031222403_remove_suppliers_and_distributors.rb new file mode 100644 index 0000000000..ece31be171 --- /dev/null +++ b/db/migrate/20121031222403_remove_suppliers_and_distributors.rb @@ -0,0 +1,37 @@ +class RemoveSuppliersAndDistributors < ActiveRecord::Migration + def up + drop_table :suppliers + drop_table :distributors + end + + def down + create_table "distributors" do |t| + t.string :name + t.string :contact + t.string :phone + t.string :email + t.string :pickup_times + t.string :url + t.string :abn + t.string :acn + t.string :description + t.datetime :created_at + t.datetime :updated_at + t.integer :pickup_address_id + t.string :next_collection_at + t.text :long_description + end + + create_table "suppliers" do |t| + t.string :name + t.string :description + t.string :email + t.string :twitter + t.string :website + t.datetime :created_at + t.datetime :updated_at + t.integer :address_id + t.text :long_description + end + end +end diff --git a/db/schema.rb b/db/schema.rb index c03b5d21f4..197f21417b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20121028070200) do +ActiveRecord::Schema.define(:version => 20121031222403) do create_table "cms_blocks", :force => true do |t| t.integer "page_id", :null => false @@ -130,23 +130,6 @@ ActiveRecord::Schema.define(:version => 20121028070200) do add_index "cms_snippets", ["site_id", "identifier"], :name => "index_cms_snippets_on_site_id_and_identifier", :unique => true add_index "cms_snippets", ["site_id", "position"], :name => "index_cms_snippets_on_site_id_and_position" - create_table "distributors", :force => true do |t| - t.string "name" - t.string "contact" - t.string "phone" - t.string "email" - t.string "pickup_times" - t.string "url" - t.string "abn" - t.string "acn" - t.string "description" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "pickup_address_id" - t.string "next_collection_at" - t.text "long_description" - end - create_table "enterprises", :force => true do |t| t.string "name" t.string "description" @@ -793,16 +776,4 @@ ActiveRecord::Schema.define(:version => 20121028070200) do t.integer "zone_members_count", :default => 0 end - create_table "suppliers", :force => true do |t| - t.string "name" - t.string "description" - t.string "email" - t.string "twitter" - t.string "website" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "address_id" - t.text "long_description" - end - end diff --git a/spec/controllers/distributors_controller_spec.rb b/spec/controllers/distributors_controller_spec.rb deleted file mode 100644 index 488ee24b39..0000000000 --- a/spec/controllers/distributors_controller_spec.rb +++ /dev/null @@ -1,75 +0,0 @@ -require 'spec_helper' -require 'spree/core/current_order' - -describe DistributorsController do - include Spree::Core::CurrentOrder - - before :each do - stub!(:before_save_new_order) - stub!(:after_save_new_order) - - create(:itemwise_shipping_method) - end - - - it "selects distributors" do - d = create(:distributor) - - spree_get :select, :id => d.id - response.should be_redirect - - order = current_order(false) - order.distributor.should == d - end - - it "deselects distributors" do - d = create(:distributor) - order = current_order(true) - order.distributor = d - order.save! - - spree_get :deselect - response.should be_redirect - - order.reload - order.distributor.should be_nil - end - - context "when a product has been added to the cart" do - it "does not allow selecting another distributor" do - # Given some distributors and an order with a product - d1 = create(:distributor) - d2 = create(:distributor) - p = create(:product, :distributors => [d1]) - o = current_order(true) - - o.distributor = d1 - o.save! - o.add_variant(p.master, 1) - - # When I attempt to select a distributor - spree_get :select, :id => d2.id - - # Then my distributor should remain unchanged - o.reload - o.distributor.should == d1 - end - - it "does not allow deselecting distributors" do - # Given a distributor and an order with a product - d = create(:distributor) - p = create(:product, :distributors => [d]) - o = current_order(true) - o.distributor = d - o.save! - o.add_variant(p.master, 1) - - # When I attempt to deselect the distributor - spree_get :deselect - - # Then my distributor should remain unchanged - o.reload - o.distributor.should == d - end - end -end diff --git a/spec/factories.rb b/spec/factories.rb index 7ecae25065..79d26f5731 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -20,27 +20,6 @@ FactoryGirl.define do is_distributor true end - factory :supplier, :class => Supplier do - sequence(:name) { |n| "Supplier #{n}" } - description 'supplier' - long_description '

Hello, world!

This is a paragraph.

' - email 'supplier@example.com' - address { Spree::Address.first || FactoryGirl.create(:address) } - end - - factory :distributor, :class => Distributor do - sequence(:name) { |n| "Distributor #{n}" } - contact 'Mr Turing' - phone '1000100100' - description 'The creator' - long_description '

Hello, world!

This is a paragraph.

' - email 'alan@somewhere.com' - url 'http://example.com' - pickup_times "Whenever you're free" - next_collection_at 'Thursday 10am' - pickup_address { Spree::Address.first || FactoryGirl.create(:address) } - end - factory :product_distribution, :class => ProductDistribution do product { |pd| Spree::Product.first || FactoryGirl.create(:product) } distributor { |pd| Enterprise.is_distributor.first || FactoryGirl.create(:distributor_enterprise) } diff --git a/spec/requests/admin/distributors_spec.rb b/spec/requests/admin/distributors_spec.rb deleted file mode 100644 index d409eba3ff..0000000000 --- a/spec/requests/admin/distributors_spec.rb +++ /dev/null @@ -1,80 +0,0 @@ -require "spec_helper" - -feature %q{ - As an administration - I want manage the distributors of products -} do - include AuthenticationWorkflow - include WebHelper - - - scenario "listing distributors" do - d = create(:distributor) - - login_to_admin_section - click_link 'Distributors' - - page.should have_content d.name - end - - scenario "viewing a distributor" do - d = create(:distributor) - - login_to_admin_section - click_link 'Distributors' - click_link d.name - - page.should have_content d.name - end - - scenario "creating a new distributor" do - login_to_admin_section - - click_link 'Distributors' - click_link 'New Distributor' - - fill_in 'distributor_name', :with => 'Eaterprises' - fill_in 'distributor_description', :with => 'Connecting farmers and eaters' - fill_in 'distributor_long_description', :with => 'Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro.' - fill_in 'distributor_contact', :with => 'Kirsten or Ren' - fill_in 'distributor_phone', :with => '0413 897 321' - - fill_in 'distributor_pickup_address_attributes_address1', :with => '35 Ballantyne St' - fill_in 'distributor_pickup_address_attributes_city', :with => 'Thornbury' - fill_in 'distributor_pickup_address_attributes_zipcode', :with => '3072' - select('Australia', :from => 'distributor_pickup_address_attributes_country_id') - select('Victoria', :from => 'distributor_pickup_address_attributes_state_id') - - fill_in 'distributor_next_collection_at', :with => 'Thursday, 22nd Feb, 6 - 9 PM' - fill_in 'distributor_pickup_times', :with => 'Thursday, 22nd Feb, 6 - 9 PM. Friday, 23nd Feb, 6 - 9 PM' - fill_in 'distributor_email', :with => 'info@eaterprises.com.au' - fill_in 'distributor_url', :with => 'http://eaterprises.com.au' - fill_in 'distributor_abn', :with => '09812309823' - fill_in 'distributor_acn', :with => '' - - click_button 'Create' - - flash_message.should == 'Distributor "Eaterprises" has been successfully created!' - end - - - scenario "updating many distributor next collection times at once" do - # Given three distributors - 3.times { create(:distributor) } - - # When I go to the distributors page - login_to_admin_section - click_link 'Distributors' - - # And I fill in some new collection times and save them - fill_in 'distributor_set_distributors_attributes_0_next_collection_at', :with => 'One' - fill_in 'distributor_set_distributors_attributes_1_next_collection_at', :with => 'Two' - fill_in 'distributor_set_distributors_attributes_2_next_collection_at', :with => 'Three' - click_button 'Update' - - # Then my times should have been saved - flash_message.should == 'Distributor collection times updated.' - Distributor.all.map { |d| d.next_collection_at }.should == %w(One Two Three) - end - -end diff --git a/spec/requests/admin/suppliers_spec.rb b/spec/requests/admin/suppliers_spec.rb deleted file mode 100644 index acd91568be..0000000000 --- a/spec/requests/admin/suppliers_spec.rb +++ /dev/null @@ -1,56 +0,0 @@ -require "spec_helper" - -feature %q{ - As an administration - I want manage the suppliers of products -} do - include AuthenticationWorkflow - include WebHelper - - background do - end - - scenario "listing suppliers" do - s = create(:supplier) - - login_to_admin_section - click_link 'Suppliers' - - page.should have_content s.name - end - - scenario "viewing a supplier" do - s = create(:supplier) - - login_to_admin_section - click_link 'Suppliers' - click_link s.name - - page.should have_content s.name - end - - scenario "creating a new supplier" do - login_to_admin_section - - click_link 'Suppliers' - click_link 'New Supplier' - - fill_in 'supplier_name', :with => 'David Arnold' - fill_in 'supplier_description', :with => 'A farmer with a difference' - fill_in 'supplier_long_description', :with => 'Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro.' - - fill_in 'supplier_address_attributes_address1', :with => '35 Byron Ave' - fill_in 'supplier_address_attributes_city', :with => 'Ararat' - fill_in 'supplier_address_attributes_zipcode', :with => '1112' - select('Australia', :from => 'supplier_address_attributes_country_id') - select('Victoria', :from => 'supplier_address_attributes_state_id') - - fill_in 'supplier_email', :with => 'david@here.com' - fill_in 'supplier_website', :with => 'http://somewhere.com' - fill_in 'supplier_twitter', :with => 'davida' - - click_button 'Create' - - flash_message.should == 'Supplier "David Arnold" has been successfully created!' - end -end