Skip to content

Commit b789fc5

Browse files
committed
Add a spec test for prov_get_form_vars
1 parent 33d2d9b commit b789fc5

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

spec/controllers/application_controller/miq_request_methods_spec.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,47 @@
6666
end
6767
end
6868

69+
describe '#prov_get_form_vars' do
70+
before { stub_user(:features => %w[miq_request_edit]) }
71+
72+
context "with an AutomationManager Provision Workflow" do
73+
let(:dialog) { FactoryBot.create(:miq_provision_configuration_script_dialog) }
74+
let(:wf) { MiqProvisionConfigurationScriptWorkflow.new({:provision_dialog_name => dialog.name}, User.current_user.userid) }
75+
let(:ems) { FactoryBot.create(:automation_manager, :url => "http://automation.localdomain") }
76+
let(:config_script) { FactoryBot.create(:configuration_script, :manager => ems) }
77+
78+
it "sets the src_configuration_script_id" do
79+
wf.instance_variable_set(
80+
:@dialogs,
81+
{
82+
:dialogs => {
83+
:service => {
84+
:fields => {
85+
:src_configuration_script_id => {
86+
:description => "Configuration Script",
87+
:required => true,
88+
:display => :edit,
89+
:data_type => :integer,
90+
:values => [
91+
OpenStruct.new(:id => config_script.id, :evm_object_class => :ConfigurationScriptBase, :name => config_script.name, :manager_name => ems.name)
92+
]
93+
}
94+
}
95+
}
96+
}
97+
}
98+
)
99+
100+
controller.params = {"service__src_configuration_script_id" => config_script.id.to_s, "id" => "new", "controller" => "miq_request", "action" => "prov_field_changed"}
101+
controller.instance_variable_set(:@edit, :wf => wf, :new => {})
102+
controller.send(:prov_get_form_vars)
103+
104+
edit = controller.instance_variable_get(:@edit)
105+
expect(edit.dig(:new, :src_configuration_script_id)).to eq([config_script.id, config_script.name])
106+
end
107+
end
108+
end
109+
69110
describe '#prov_edit' do
70111
it 'redirects to the last link in breadcrumbs' do
71112
allow_any_instance_of(described_class).to receive(:set_user_time_zone)

0 commit comments

Comments
 (0)