From 4aafba664cd7aaef94c17c3909da0b3dc2f1cc9f Mon Sep 17 00:00:00 2001 From: Jillian Tullo Date: Fri, 3 Mar 2017 09:52:19 -0500 Subject: [PATCH] don't allow for prov_type and service_type to be changed --- app/models/service_template.rb | 7 ++++++- .../service_template_orchestration_spec.rb | 7 ------- spec/models/service_template_spec.rb | 19 +++++++++++++++++-- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/app/models/service_template.rb b/app/models/service_template.rb index f02ba3eb23f..dc228e826f8 100644 --- a/app/models/service_template.rb +++ b/app/models/service_template.rb @@ -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 diff --git a/spec/models/service_template_orchestration_spec.rb b/spec/models/service_template_orchestration_spec.rb index 202d8452e8e..ab322726369 100644 --- a/spec/models/service_template_orchestration_spec.rb +++ b/spec/models/service_template_orchestration_spec.rb @@ -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) diff --git a/spec/models/service_template_spec.rb b/spec/models/service_template_spec.rb index 36ab5ff196a..40f36ec47ea 100644 --- a/spec/models/service_template_spec.rb +++ b/spec/models/service_template_spec.rb @@ -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