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