Skip to content

Commit

Permalink
Fixed condition to use correct feature id
Browse files Browse the repository at this point in the history
Fixed condition to use correct feature id when goign to tagging from summary screen directly. #4843 did not cover all scenarios.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1684472
  • Loading branch information
h-kataria committed Mar 20, 2019
1 parent 742e49f commit 197f5e3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller/tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 17 additions & 3 deletions spec/controllers/application_controller/tags_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 197f5e3

Please sign in to comment.