Skip to content

Commit

Permalink
Merge pull request #727 from himdel/bz1428905-handle-empty-target-class
Browse files Browse the repository at this point in the history
MiqAeTools - simulate - handle unsetting Object Attribute type
(cherry picked from commit 6e3ac1b)

https://bugzilla.redhat.com/show_bug.cgi?id=1434157
  • Loading branch information
mzazrivec authored and simaishi committed Mar 20, 2017
1 parent 58cbec8 commit 61d2ecf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/miq_ae_tools_controller.rb
Expand Up @@ -439,7 +439,7 @@ def get_form_vars
# @resolve[:new][:target_attr_name] = params[:target_attr_name] if params.has_key?(:target_attr_name)
if params.key?(:target_class)
@resolve[:new][:target_class] = params[:target_class]
targets = Rbac.filtered(params[:target_class]).select(:id, :name)
targets = Rbac.filtered(params[:target_class]).select(:id, :name) unless params[:target_class].blank?
unless targets.nil?
@resolve[:targets] = targets.sort_by { |t| t.name.downcase }.collect { |t| [t.name, t.id.to_s] }
@resolve[:new][:target_id] = nil
Expand Down
13 changes: 13 additions & 0 deletions spec/controllers/miq_ae_tools_controller_spec.rb
Expand Up @@ -5,6 +5,19 @@

context "#form_field_changed" do
it "resets target id to nil, when target class is <none>" do
new = {
:target_class => "EmsCluster",
:target_id => 1
}
controller.instance_variable_set(:@resolve, :throw_ready => true, :new => new)
expect(controller).to receive(:render)
controller.instance_variable_set(:@_params, :target_class => '', :id => 'new')
controller.send(:form_field_changed)
expect(assigns(:resolve)[:new][:target_class]).to eq('')
expect(assigns(:resolve)[:new][:target_id]).to eq(nil)
end

it "resets target id to nil, when target class is Vm" do
new = {
:target_class => "EmsCluster",
:target_id => 1
Expand Down

0 comments on commit 61d2ecf

Please sign in to comment.