Sha256: 711e5b1377981321735885e2a475f3c201996e3a1b5855f36f97756d3f165f21

Contents?: true

Size: 1.83 KB

Versions: 11

Compression:

Stored size: 1.83 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

  test 'new via GET and POST' 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
    assert_response :success

    post :new, params: params, session: set_session_user
    assert_response :success
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
foreman_remote_execution-3.3.7 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-3.3.6 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-3.3.5 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-3.3.4 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-3.3.3 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-3.2.2 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-3.3.2 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-3.3.1 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-3.3.0 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-3.2.1 test/functional/job_invocations_controller_test.rb
foreman_remote_execution-3.2.0 test/functional/job_invocations_controller_test.rb