Sha256: d4d5e28b80b1b545f2a749789949acaab0b402f24dcea80c38eea1ab9f0c102b

Contents?: true

Size: 903 Bytes

Versions: 1

Compression:

Stored size: 903 Bytes

Contents

require 'test_helper'

module KatelloForemanEngine
  module Actions
    class OrgDestroyTest < ActiveSupport::TestCase

      test "runs only when the org is present in Foreman" do
        foreman_org = { 'organization' => { 'id' => '123' } }
        Bindings.expects(:organization_find).with('KT-[test]').returns(foreman_org)
        plan = prepare_plan(OrgDestroy, {'label' => 'test'}, nil)
        step = plan.run_steps.first
        assert_equal OrgDestroy, step.action_class
        assert_equal step.input['foreman_id'], '123'

        Bindings.expects(:organization_find).returns(nil)
        plan = prepare_plan(OrgDestroy, {'label' => 'test'}, nil)
        assert_equal [], plan.run_steps
      end

      test 'calls bindings to destroy organization' do
        Bindings.expects(:organization_destroy).with('123')
        OrgDestroy.new('foreman_id' => '123').run
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
katello-foreman-engine-0.0.1 test/lib/actions/org_destroy.rb