Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed class name and key name in add/edit of user role code #11999

Merged
merged 1 commit into from
Oct 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/ops_controller/ops_rbac.rb
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ def rbac_edit_save_or_add(what, rbac_suffix = what)
when :role then
rbac_role_validate?
rbac_role_set_record_vars(
record = @edit[:user_id] ? User.find_by_id(@edit[:user_id]) : User.new)
record = @edit[:role_id] ? MiqUserRole.find_by_id(@edit[:role_id]) : MiqUserRole.new)
end

if record.valid? && !flash_errors? && record.save
Expand Down
24 changes: 24 additions & 0 deletions spec/controllers/ops_controller/ops_rbac_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -398,4 +398,28 @@
expect(edit[:current][:ldap_groups].find { |lg| lg.group_type == 'user' }).not_to be(nil)
end
end

context "rbac_role_edit" do
before do
MiqUserRole.seed
MiqGroup.seed
MiqRegion.seed
stub_user(:features => :all)
end

it "creates a new user role successfully" do
allow(controller).to receive(:replace_right_cell)
controller.instance_variable_set(:@_params, :button => "add")
new = {:features => ["everything"], :name => "foo"}
edit = {:key => "rbac_role_edit__new",
:new => new,
:current => new
}
session[:edit] = edit
controller.send(:rbac_role_edit)
flash_messages = assigns(:flash_array)
expect(flash_messages.first[:message]).to include("Role \"foo\" was saved")
expect(controller.send(:flash_errors?)).to be_falsey
end
end
end