Sha256: 85fc16aa70adbf47e7c9c23d66632955efd2d473f41d7cbbe2b0d46c208d2ddb

Contents?: true

Size: 1.83 KB

Versions: 31

Compression:

Stored size: 1.83 KB

Contents

# frozen_string_literal: true

require 'test_plugin_helper'
# functional tests for AnsibleVariablesController
class AnsibleVariablesControllerTest < ActionController::TestCase
  setup do
    @model = FactoryBot.create(:ansible_variable)
    @proxy = FactoryBot.create(:smart_proxy, :with_ansible)
  end

  basic_index_test
  basic_edit_test @variable
  basic_pagination_per_page_test
  basic_pagination_rendered_test

  test 'should destroy variable' do
    assert_difference('AnsibleVariable.count', -1) do
      delete :destroy,
             :params => { :id => @model.id },
             :session => set_session_user
    end
    assert_redirected_to ansible_variables_url
  end

  test 'there are no problems when the import hash is empty' do
    ForemanAnsible::VariablesImporter.any_instance.
      expects(:import_variable_names).returns({})
    ForemanAnsible::UiRolesImporter.any_instance.
      expects(:import_role_names).returns({})

    get :import,
        :params => { :proxy => @proxy.id },
        :session => set_session_user
    assert_redirected_to ansible_variables_url
  end

  test 'should show import page' do
    ForemanAnsible::UiRolesImporter.any_instance.
      expects(:import_role_names).returns({})

    ForemanAnsible::VariablesImporter.any_instance.
      expects(:import_variable_names).returns({
        :obsolete => [@model]
      })

    get :import,
        :params => { :proxy => @proxy.id },
        :session => set_session_user
    assert_response :success
  end

  test 'should create ansible variable' do
    params = { :ansible_variable => { :key => 'great name', :ansible_role_id => FactoryBot.create(:ansible_role).id } }
    assert_difference('AnsibleVariable.count', 1) do
      post :create,
           :params => params,
           :session => set_session_user
    end
    assert_redirected_to ansible_variables_url
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
foreman_ansible-6.2.0 test/functional/ansible_variables_controller_test.rb
foreman_ansible-6.1.1 test/functional/ansible_variables_controller_test.rb
foreman_ansible-6.0.2 test/functional/ansible_variables_controller_test.rb
foreman_ansible-6.1.0 test/functional/ansible_variables_controller_test.rb
foreman_ansible-6.0.1 test/functional/ansible_variables_controller_test.rb
foreman_ansible-5.1.3 test/functional/ansible_variables_controller_test.rb
foreman_ansible-6.0.0 test/functional/ansible_variables_controller_test.rb
foreman_ansible-5.1.2 test/functional/ansible_variables_controller_test.rb
foreman_ansible-5.1.1 test/functional/ansible_variables_controller_test.rb
foreman_ansible-5.1.0 test/functional/ansible_variables_controller_test.rb
foreman_ansible-4.0.3.5 test/functional/ansible_variables_controller_test.rb
foreman_ansible-4.0.3.4 test/functional/ansible_variables_controller_test.rb
foreman_ansible-4.0.3.3 test/functional/ansible_variables_controller_test.rb
foreman_ansible-4.0.3.2 test/functional/ansible_variables_controller_test.rb
foreman_ansible-5.0.1 test/functional/ansible_variables_controller_test.rb
foreman_ansible-4.0.5 test/functional/ansible_variables_controller_test.rb
foreman_ansible-4.0.3.1 test/functional/ansible_variables_controller_test.rb
foreman_ansible-4.0.4 test/functional/ansible_variables_controller_test.rb
foreman_ansible-5.0.0 test/functional/ansible_variables_controller_test.rb
foreman_ansible-4.0.3 test/functional/ansible_variables_controller_test.rb