Sha256: 693e470ccf6e3503cb383ccc4ccdcb7414be3a61903c1b2026895c56b7c6cb85

Contents?: true

Size: 926 Bytes

Versions: 23

Compression:

Stored size: 926 Bytes

Contents

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

23 entries across 23 versions & 1 rubygems

Version Path
foreman_ansible-2.2.14 test/unit/services/ui_roles_importer_test.rb
foreman_ansible-2.2.13 test/unit/services/ui_roles_importer_test.rb
foreman_ansible-2.2.12 test/unit/services/ui_roles_importer_test.rb
foreman_ansible-2.2.11 test/unit/services/ui_roles_importer_test.rb
foreman_ansible-2.2.10 test/unit/services/ui_roles_importer_test.rb
foreman_ansible-2.2.9 test/unit/services/ui_roles_importer_test.rb
foreman_ansible-2.2.8 test/unit/services/ui_roles_importer_test.rb
foreman_ansible-2.2.7 test/unit/services/ui_roles_importer_test.rb
foreman_ansible-2.2.6 test/unit/services/ui_roles_importer_test.rb
foreman_ansible-2.2.5 test/unit/services/ui_roles_importer_test.rb
foreman_ansible-2.2.4 test/unit/services/ui_roles_importer_test.rb
foreman_ansible-2.2.3 test/unit/services/ui_roles_importer_test.rb
foreman_ansible-2.2.2 test/unit/services/ui_roles_importer_test.rb
foreman_ansible-2.2.1 test/unit/services/ui_roles_importer_test.rb
foreman_ansible-2.2.0 test/unit/services/ui_roles_importer_test.rb
foreman_ansible-2.1.2 test/unit/services/ui_roles_importer_test.rb
foreman_ansible-2.1.1 test/unit/services/ui_roles_importer_test.rb
foreman_ansible-2.0.4 test/unit/services/ui_roles_importer_test.rb
foreman_ansible-2.0.3 test/unit/services/ui_roles_importer_test.rb
foreman_ansible-2.0.2 test/unit/services/ui_roles_importer_test.rb