Sha256: 2e2e1a3a9479a848f57d79555554c8f077351d0f69bd0254e8a4a00eab1901f7

Contents?: true

Size: 1.47 KB

Versions: 6

Compression:

Stored size: 1.47 KB

Contents

require 'test_plugin_helper'

module InventoryUpload::Api
  class InventoryControllerTest < ActionController::TestCase
    tests Api::V2::RhCloud::InventoryController

    setup do
      @test_org = FactoryBot.create(:organization)
      @disconnected = false
    end

    test 'Starts report generation' do
      Api::V2::RhCloud::InventoryController.any_instance
        .expects(:start_report_generation)
        .with(@test_org.id.to_s, @disconnected)

      post :generate_report, params: { organization_id: @test_org.id, disconnected: @disconnected }

      assert_response :success
    end

    test 'Starts inventory sync action' do
      test_task = FactoryBot.create(:some_task)

      Api::V2::RhCloud::InventoryController.any_instance
        .expects(:start_inventory_sync)
        .with() { |actual_org| @test_org.id == actual_org.id }
        .returns(test_task)

      post :sync_inventory_status, params: { organization_id: @test_org.id }

      assert_response :success

      assert_not_nil(actual_task = @response.parsed_body['task'])
      assert_equal test_task.id.to_s, actual_task['id']
    end

    test 'Starts cloud connector configuration job' do
      test_job = FactoryBot.create(:job_invocation)

      ForemanRhCloud::CloudConnector.any_instance
        .expects(:install)
        .returns(test_job)

      post :enable_cloud_connector

      assert_response :success

      actual_job = @response.parsed_body

      assert_equal test_job.id, actual_job['id']
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
foreman_rh_cloud-10.0.3 test/controllers/inventory_upload/api/inventory_controller_test.rb
foreman_rh_cloud-11.0.3 test/controllers/inventory_upload/api/inventory_controller_test.rb
foreman_rh_cloud-11.0.2 test/controllers/inventory_upload/api/inventory_controller_test.rb
foreman_rh_cloud-11.0.1 test/controllers/inventory_upload/api/inventory_controller_test.rb
foreman_rh_cloud-11.0.0 test/controllers/inventory_upload/api/inventory_controller_test.rb
foreman_rh_cloud-10.0.2 test/controllers/inventory_upload/api/inventory_controller_test.rb