|
66 | 66 | end |
67 | 67 | end |
68 | 68 |
|
| 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 | + |
69 | 110 | describe '#prov_edit' do |
70 | 111 | it 'redirects to the last link in breadcrumbs' do |
71 | 112 | allow_any_instance_of(described_class).to receive(:set_user_time_zone) |
|
0 commit comments