Sha256: 884a90ca0cbdc9ae38bdedad7323d7222f284867432e1399e8165cc8061b8936

Contents?: true

Size: 1.01 KB

Versions: 39

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

require 'test_plugin_helper'
# unit tests for ApiRolesImporter
class ApiRolesImporterTest < ActiveSupport::TestCase
  setup do
    @importer = ForemanAnsible::ApiRolesImporter.new
    first_name = 'test_user.test_name'
    second_name = 'some_user.some_role'
    @test_roles = [AnsibleRole.new(:name => first_name),
                   AnsibleRole.new(:name => second_name)]
  end

  test 'should import roles' do
    @importer.stubs(:import_role_names).returns(:new => @test_roles)
    res = @importer.import!
    assert_equal 2, res.count
    assert AnsibleRole.find_by :name => @test_roles.first.name
    assert AnsibleRole.find_by :name => @test_roles.last.name
  end

  test 'should obsolete roles' do
    @importer.stubs(:import_role_names).returns(:obsolete => @test_roles)
    @test_roles.map(&:save)
    res = @importer.obsolete!
    assert_equal 2, res.count
    refute AnsibleRole.find_by :name => @test_roles.first.name
    refute AnsibleRole.find_by :name => @test_roles.last.name
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

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