mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Fix bug where new enterprises should be created as hubs, but aren't
This commit is contained in:
@@ -150,7 +150,7 @@ module Admin
|
||||
def override_sells
|
||||
unless spree_current_user.admin?
|
||||
has_hub = spree_current_user.owned_enterprises.is_hub.any?
|
||||
new_enterprise_is_producer = !!params[:enterprise][:is_primary_producer]
|
||||
new_enterprise_is_producer = Enterprise.new(params[:enterprise]).is_primary_producer
|
||||
params[:enterprise][:sells] = (has_hub && !new_enterprise_is_producer) ? 'any' : 'none'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -20,7 +20,7 @@ module Admin
|
||||
describe "creating an enterprise" do
|
||||
let(:country) { Spree::Country.find_by_name 'Australia' }
|
||||
let(:state) { Spree::State.find_by_name 'Victoria' }
|
||||
let(:enterprise_params) { {enterprise: {name: 'zzz', permalink: 'zzz', email: "bob@example.com", address_attributes: {address1: 'a', city: 'a', zipcode: 'a', country_id: country.id, state_id: state.id}}} }
|
||||
let(:enterprise_params) { {enterprise: {name: 'zzz', permalink: 'zzz', is_primary_producer: '0', email: "bob@example.com", address_attributes: {address1: 'a', city: 'a', zipcode: 'a', country_id: country.id, state_id: state.id}}} }
|
||||
|
||||
it "grants management permission if the current user is an enterprise user" do
|
||||
controller.stub spree_current_user: distributor_manager
|
||||
|
||||
Reference in New Issue
Block a user