Skip to content

Commit

Permalink
don't allow for prov_type and service_type to be changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Jillian Tullo committed Mar 3, 2017
1 parent a8947bc commit 4aafba6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
7 changes: 6 additions & 1 deletion app/models/service_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,12 @@ def build_resource_action(ae_endpoint, action)
end

def validate_update_config_info(options)
raise _('service_type and prov_type cannot be changed') if options[:service_type] || options[:prov_type]
if options[:service_type] && options[:service_type] != service_type
raise _('service_type cannot be changed')
end
if options[:prov_type] && options[:prov_type] != prov_type
raise _('prov_type cannot be changed')
end
options[:config_info]
end

Expand Down
7 changes: 0 additions & 7 deletions spec/models/service_template_orchestration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,6 @@
end.to raise_error(StandardError, 'Must provide both template_id and manager_id or manager and template')
end

it 'cannot change service_type or prov_type' do
updated_catalog_item_options[:prov_type] = 'new type'
expect do
@catalog_item.update_catalog_item(updated_catalog_item_options)
end.to raise_error(StandardError, 'service_type and prov_type cannot be changed')
end

it 'can accept manager and template objects on update' do
updated_catalog_item_options[:config_info].delete(:manager_id)
updated_catalog_item_options[:config_info].delete(:manager_id)
Expand Down
19 changes: 17 additions & 2 deletions spec/models/service_template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,25 @@
expect(updated.config_info).to eq(updated_catalog_item_options[:config_info])
end

it 'does not allow service_type and prov_type to be changed' do
it 'does not allow service_type to be changed' do
expect do
@catalog_item.update_catalog_item({:service_type => 'new'}, user)
end.to raise_error(StandardError, /service_type and prov_type cannot be changed/)
end.to raise_error(StandardError, /service_type cannot be changed/)
end

it 'does not allow prov_type to be changed' do
expect do
@catalog_item.update_catalog_item({:prov_type => 'new'}, user)
end.to raise_error(StandardError, /prov_type cannot be changed/)
end

it 'accepts prov_type and service_type if they are not changed' do
expect do
@catalog_item.update_catalog_item({:name => 'new_name',
:service_type => @catalog_item.service_type,
:prov_type => @catalog_item.prov_type}, user)
end.to change(@catalog_item, :name)
expect(@catalog_item.reload.name).to eq('new_name')
end

it 'allows for update without the presence of config_info' do
Expand Down

0 comments on commit 4aafba6

Please sign in to comment.