Fix bug where new enterprises should be created as hubs, but aren't

This commit is contained in:
Rohan Mitchell
2015-04-10 11:14:56 +10:00
parent 48bf87ec73
commit 2e021941d1
2 changed files with 2 additions and 2 deletions

View File

@@ -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

View File

@@ -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