Sha256: 3512b279db74f70f6059b811c274b16ca6e8890c63d169efb5650eeabb980d37

Contents?: true

Size: 957 Bytes

Versions: 39

Compression:

Stored size: 957 Bytes

Contents

# frozen_string_literal: true

require 'test_plugin_helper'
# unit tests for UiRolesImporter
class UiRolesImporterTest < ActiveSupport::TestCase
  setup do
    changed_roles
    @importer = ForemanAnsible::UiRolesImporter.new
  end

  test 'should create new role' do
    refute AnsibleRole.find_by(:name => @new_role[:name])
    @importer.create_new_roles(@changes['new'])
    assert AnsibleRole.find_by(:name => @new_role[:name])
  end

  test 'should delete old roles' do
    assert AnsibleRole.find_by(:name => @role.name)
    @importer.delete_old_roles(@changes['obsolete'])
    refute AnsibleRole.find_by(:name => @role.name)
  end

  private

  def changed_roles
    @role = FactoryBot.create(:ansible_role)
    new_role_name = 'test_role.foreman'
    @new_role = { :id => nil, :name => new_role_name }
    @changes = { 'new' => { 'test_role.foreman' => @new_role.to_json },
                 'obsolete' => { @role.name => @role.to_json } }
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

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