mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-03 02:21:33 +00:00
Require shipping methods to have at least one distributor
This commit is contained in:
@@ -3,6 +3,8 @@ Spree::ShippingMethod.class_eval do
|
||||
attr_accessible :distributor_ids, :description
|
||||
attr_accessible :require_ship_address
|
||||
|
||||
validates :distributors, presence: { message: "^At least one hub must be selected" }
|
||||
|
||||
scope :managed_by, lambda { |user|
|
||||
if user.has_spree_role?('admin')
|
||||
scoped
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
- hubs_color = @hubs.count > 0 ? "blue" : "red"
|
||||
- hubs_color = 'red' if (controller.action_name == 'create' || controller.action_name == 'update') && @object.errors.full_messages.include?("At least one hub must be selected")
|
||||
.sidebar_item.omega.four.columns#hubs
|
||||
.four.columns.alpha.header{ class: "#{hubs_color}" }
|
||||
%span.four.columns.alpha.centered Distributors
|
||||
%span.four.columns.alpha.centered Hubs
|
||||
.four.columns.alpha.list{ class: "#{hubs_color}" }
|
||||
- if @hubs.count > 0
|
||||
-# = hidden_field_tag "enterprise[hub_ids][]", []
|
||||
= f.hidden_field :distributor_ids, :multiple => true, value: nil
|
||||
- @hubs.each do |hub|
|
||||
%a.four.columns.alpha.list-item{ class: "#{cycle('odd','even')}", href: "#{main_app.edit_admin_enterprise_path(hub)}" }
|
||||
%span.three.columns.alpha
|
||||
|
||||
@@ -110,16 +110,17 @@ feature %q{
|
||||
|
||||
scenario "editing an existing enterprise" do
|
||||
@enterprise = create(:enterprise)
|
||||
e2 = create(:enterprise)
|
||||
eg1 = create(:enterprise_group, name: 'eg1')
|
||||
eg2 = create(:enterprise_group, name: 'eg2')
|
||||
payment_method = create(:payment_method, distributors: [])
|
||||
shipping_method = create(:shipping_method, distributors: [])
|
||||
shipping_method = create(:shipping_method, distributors: [e2])
|
||||
enterprise_fee = create(:enterprise_fee, enterprise: @enterprise )
|
||||
|
||||
login_to_admin_section
|
||||
|
||||
click_link 'Enterprises'
|
||||
click_link 'Edit Profile'
|
||||
all("a", text:'Edit Profile').first.click
|
||||
|
||||
fill_in 'enterprise_name', :with => 'Eaterprises'
|
||||
fill_in 'enterprise_description', :with => 'Connecting farmers and eaters'
|
||||
|
||||
Reference in New Issue
Block a user