Sha256: 510b2a49882a4f4bd21e9e88eb0eeceb6442b70a80e0a39cebdc5d7ba5d95a43

Contents?: true

Size: 1.41 KB

Versions: 5

Compression:

Stored size: 1.41 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)
  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({})

    proxy = FactoryBot.create(:smart_proxy, :with_ansible)
    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

5 entries across 5 versions & 1 rubygems

Version Path
foreman_ansible-2.3.6 test/functional/ansible_variables_controller_test.rb
foreman_ansible-2.3.5 test/functional/ansible_variables_controller_test.rb
foreman_ansible-2.3.4 test/functional/ansible_variables_controller_test.rb
foreman_ansible-3.0.0 test/functional/ansible_variables_controller_test.rb
foreman_ansible-2.3.3 test/functional/ansible_variables_controller_test.rb