diff --git a/app/controllers/application_controller/tags.rb b/app/controllers/application_controller/tags.rb index 7886a676c139..5ce5e0010571 100644 --- a/app/controllers/application_controller/tags.rb +++ b/app/controllers/application_controller/tags.rb @@ -3,7 +3,7 @@ module ApplicationController::Tags # Edit user, group or tenant tags def tagging_edit(db = nil, assert = true) - assert_privileges("#{@display ? @display.singularize : controller_for_common_methods}_tag") if assert + assert_privileges("#{@display && @display != "main" ? @display.singularize : controller_for_common_methods}_tag") if assert @explorer = true if request.xml_http_request? # Ajax request means in explorer @tagging = session[:tag_db] = params[:db] ? params[:db] : db if params[:db] || db diff --git a/spec/controllers/application_controller/tags_spec.rb b/spec/controllers/application_controller/tags_spec.rb index de6dfb07f107..099bd160ecb2 100644 --- a/spec/controllers/application_controller/tags_spec.rb +++ b/spec/controllers/application_controller/tags_spec.rb @@ -114,14 +114,28 @@ def convert_to_region_id(id) describe EmsInfraController do before do - login_as FactoryBot.create(:user, :features => %w(storage_tag)) + login_as FactoryBot.create(:user, :features => %w(storage_tag ems_infra_tag)) controller.instance_variable_set(:@_params, params) - controller.instance_variable_set(:@display, "storages") end - context 'check for correct feature id when tagging selected storage thru Provider relationship' do + context 'check for correct feature id when tagging selected storage thru Provider relationship and directly from summary screen' do let(:params) { {:db => "Storage", :id => "1"} } + let(:controller_name) { Storage } it 'sets @tagging properly' do + controller.instance_variable_set(:@display, "storages") + allow(controller).to receive(:tagging_edit_tags_reset) + controller.send(:tagging_edit) + expect(controller.instance_variable_get(:@tagging)).not_to be_nil + end + + it 'checks proper feature id when trying to go to tagging directly from a summary screen' do + controller.instance_variable_set(:@display, "main") + allow(controller).to receive(:tagging_edit_tags_reset) + controller.send(:tagging_edit) + expect(controller.instance_variable_get(:@tagging)).not_to be_nil + end + + it 'checks proper feature id when trying to go to tagging from list view and @dsiplay is not set' do allow(controller).to receive(:tagging_edit_tags_reset) controller.send(:tagging_edit) expect(controller.instance_variable_get(:@tagging)).not_to be_nil