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

Clear the request field when switching the button type to 'Default' #3787

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
1 change: 1 addition & 0 deletions app/controllers/mixins/playbook_options.rb
Expand Up @@ -56,6 +56,7 @@ def clear_playbook_variables
@edit[:new][:service_template_id] = nil
@edit[:new][:inventory_type] = 'localhost'
@edit[:new][:hosts] = ''
@edit[:new][:object_request] = nil
end

def initialize_playbook_variables
Expand Down
Expand Up @@ -98,6 +98,31 @@
expect(assigns(:sb)[:active_tab]).to eq("ab_advanced_tab")
end

it "the request field is cleared when the button type is changed from Playbook to Default" do
@sb = {:active_tree => :ab_tree,
:trees => {:ab_tree => {:tree => :ab_tree}},
:params => {:instance_name => 'MiqEvent'}}
controller.instance_variable_set(:@sb, @sb)
controller.instance_variable_set(:@breadcrumbs, [])

edit = {:new => {:button_images => %w(01 02 03), :available_dialogs => {:id => '01', :name => '02'},
:instance_name => 'MiqEvent',
:attrs => [%w(Attr1 01), %w(Attr2 02), %w(Attr3 03), %w(Attr4 04), %w(Attr5 05)],
:disabled_text => 'a_disabled_text',
:object_request => CustomButton::PLAYBOOK_METHOD,
:button_type => 'ansible_playbook'},
:instance_names => %w(CustomButton_1 CustomButton_2),
:visibility_types => %w(Type1 Type2),
:ansible_playbooks => [],
:current => {}}
controller.instance_variable_set(:@edit, edit)
session[:edit] = edit
session[:resolve] = {}
post :automate_button_field_changed, :params => {:id => 'new', :button_type => "default"}
@edit = controller.instance_variable_get(:@edit)
expect(@edit[:new][:object_request]).to be_nil
end

it "uses available expression fields when editing the custom buttons expressions" do
allow(MiqAeClass).to receive_messages(:find_distinct_instances_across_domains => [double(:name => "foo")])

Expand Down