Sha256: d3e0a027ebf76a68514b72aab196fa46e4f1853ef074354c21240201957b13d7

Contents?: true

Size: 1.44 KB

Versions: 38

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

require 'test_plugin_helper'

class JobInvocationsControllerTest < ActionController::TestCase
  test 'should parse inputs coming from the URL params' do
    template = FactoryBot.create(:job_template, :with_input)
    feature = FactoryBot.create(:remote_execution_feature,
                                :job_template => template)
    params = {
      feature: feature.label,
      inputs: { template.template_inputs.first.name => 'foobar' }
    }

    get :new, params: params, session: set_session_user
    template_invocation_params = [
      {
        'input_values' =>
        [
          {
            'value' => 'foobar',
            'template_input_id' => template.template_inputs.first.id
          }
        ],
        'template_id' => template.id
      }
    ]
    assert_equal(template_invocation_params,
                 assigns(:composer).params['template_invocations'])
  end

  test 'should allow no inputs' do
    template = FactoryBot.create(:job_template)
    feature = FactoryBot.create(:remote_execution_feature,
                                :job_template => template)
    params = {
      feature: feature.label,
    }
    get :new, params: params, session: set_session_user
    template_invocation_params = [
      {
        'template_id' => template.id,
        'input_values' => {}
      }
    ]
    assert_equal(template_invocation_params,
                 assigns(:composer).params['template_invocations'])
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
foreman_remote_execution-2.0.10 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-2.0.9 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-2.0.8 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-3.0.3 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-3.0.2 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-2.0.7 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-3.0.1 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-3.0.0 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-2.0.6 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-2.0.5 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-2.0.4 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-2.0.3 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-2.0.2 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-2.0.1 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-2.0.0 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-1.8.4 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-1.8.3 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-1.8.2 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-1.8.1 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-1.8.0 test/functional/job_invocations_controller_test.rb