Sha256: 3915bc788179fe0cd81e1f15f4fe707baf4abe8a069d759e2b788d6bd4cf7fca

Contents?: true

Size: 1.47 KB

Versions: 10

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

10 entries across 10 versions & 1 rubygems

Version Path
foreman_rh_cloud-9.0.59 test/controllers/inventory_upload/api/inventory_controller_test.rb
foreman_rh_cloud-9.0.58 test/controllers/inventory_upload/api/inventory_controller_test.rb
foreman_rh_cloud-9.0.57 test/controllers/inventory_upload/api/inventory_controller_test.rb
foreman_rh_cloud-10.0.1 test/controllers/inventory_upload/api/inventory_controller_test.rb
foreman_rh_cloud-9.0.56 test/controllers/inventory_upload/api/inventory_controller_test.rb
foreman_rh_cloud-9.0.55 test/controllers/inventory_upload/api/inventory_controller_test.rb
foreman_rh_cloud-9.0.54 test/controllers/inventory_upload/api/inventory_controller_test.rb
foreman_rh_cloud-9.0.53 test/controllers/inventory_upload/api/inventory_controller_test.rb
foreman_rh_cloud-9.0.52 test/controllers/inventory_upload/api/inventory_controller_test.rb
foreman_rh_cloud-8.0.52 test/controllers/inventory_upload/api/inventory_controller_test.rb