Skip to content

Commit

Permalink
Merge pull request #4242 from h-kataria/catalog_item_tagging_from_sum…
Browse files Browse the repository at this point in the history
…mary

Pass in id of selected record correctly.
  • Loading branch information
Dan Clarizio authored Jul 3, 2018
2 parents c3e9ef5 + e8642a3 commit b8c990d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2196,7 +2196,8 @@ def dialog_catalog_check

def x_edit_tags_reset(db)
@tagging = session[:tag_db] = db
@object_ids = find_records_with_rbac(db.safe_constantize, find_checked_items).ids
checked_ids = find_checked_items.empty? ? [params[:id]] : find_checked_items
@object_ids = find_records_with_rbac(db.safe_constantize, checked_ids).ids
if params[:button] == 'reset'
id = params[:id] if params[:id]
return unless load_edit("#{session[:tag_db]}_edit_tags__#{id}", 'replace_cell__explorer')
Expand Down
17 changes: 15 additions & 2 deletions spec/controllers/catalog_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
controller.send(:st_delete)
end

it "checks method x_edit_tags_reset" do
it "checks method x_edit_tags_reset when multiple records selected from list view" do
login_as admin_user
allow(User).to receive(:current_user).and_return(admin_user)
allow(controller).to receive(:checked_or_params).and_return(ServiceTemplate.all.ids)
controller.params["check_1"] = '1'
controller.instance_variable_set(:@sb, :action => nil)
allow(controller).to receive(:checked_or_params).and_return(ServiceTemplate.all.ids)
allow(controller).to receive(:find_checked_items).and_return(ServiceTemplate.all.ids)
Expand All @@ -42,6 +42,19 @@
controller.send(:x_edit_tags_reset, "ServiceTemplate")
end

it "checks method x_edit_tags_reset when tagging from summary screen" do
login_as admin_user
allow(User).to receive(:current_user).and_return(admin_user)
controller.instance_variable_set(:@_params, :id => "#{service_template_with_child_tenant.id}")
controller.instance_variable_set(:@sb, :action => nil)
allow(controller).to receive(:checked_or_params).and_return([])
allow(controller).to receive(:find_checked_items).and_return([])
allow(controller).to receive(:tag_edit_build_entries_pulldown).and_return(nil)
allow(controller).to receive(:replace_right_cell).with(:action => nil)
expect(controller).to receive(:x_tags_set_form_vars)
controller.send(:x_edit_tags_reset, "ServiceTemplate")
end

context 'get_view' do
it "returns all catalog items related to current tenant and root tenant when non-self service user is logged" do
login_as child_tenant_user
Expand Down

0 comments on commit b8c990d

Please sign in to comment.