Sha256: 56f787812b0c6d6390e922c7a255adac1b743bc521e1859192dd67e868c7f76f

Contents?: true

Size: 1.62 KB

Versions: 40

Compression:

Stored size: 1.62 KB

Contents

require 'test_plugin_helper'

class SettingsControllerTest < ActionController::TestCase
  tests InsightsCloud::SettingsController

  test 'should return allow_auto_insights_sync setting' do
    Setting[:allow_auto_insights_sync] = false

    assert_equal false, Setting[:allow_auto_insights_sync]

    get :show, session: set_session_user

    assert_response :success
    actual = JSON.parse(response.body)
    assert_equal false, actual['insightsSyncEnabled']
  end

  test 'should update allow_auto_insights_sync setting' do
    Setting[:allow_auto_insights_sync] = false

    assert_equal false, Setting[:allow_auto_insights_sync]

    patch :update, params: { insightsSyncEnabled: true }, session: set_session_user

    assert_response :success
    actual = JSON.parse(response.body)
    assert_equal true, actual['insightsSyncEnabled']
    assert_equal true, Setting[:allow_auto_insights_sync]
  end

  test 'Should update an organization parameter' do
    FactoryBot.create(:common_parameter, name: InsightsCloud.enable_cloud_remediations_param, value: false)
    host = FactoryBot.create(:host)

    # make sure the parameter is there
    assert_equal false, host.host_params[InsightsCloud.enable_cloud_remediations_param]

    post :set_org_parameter, params: { parameter: InsightsCloud.enable_cloud_remediations_param, value: true, organization_id: host.organization.id }, session: set_session_user

    # needed for properly access host_params
    User.as_anonymous_admin do
      # refresh the host record
      host = Host.find(host.id)
      assert_equal true, host.host_params[InsightsCloud.enable_cloud_remediations_param]
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
foreman_rh_cloud-10.0.3 test/controllers/insights_sync/settings_controller_test.rb
foreman_rh_cloud-11.0.3 test/controllers/insights_sync/settings_controller_test.rb
foreman_rh_cloud-9.0.59 test/controllers/insights_sync/settings_controller_test.rb
foreman_rh_cloud-11.0.2 test/controllers/insights_sync/settings_controller_test.rb
foreman_rh_cloud-11.0.1 test/controllers/insights_sync/settings_controller_test.rb
foreman_rh_cloud-11.0.0 test/controllers/insights_sync/settings_controller_test.rb
foreman_rh_cloud-9.0.58 test/controllers/insights_sync/settings_controller_test.rb
foreman_rh_cloud-10.0.2 test/controllers/insights_sync/settings_controller_test.rb
foreman_rh_cloud-9.0.57 test/controllers/insights_sync/settings_controller_test.rb
foreman_rh_cloud-10.0.1 test/controllers/insights_sync/settings_controller_test.rb
foreman_rh_cloud-9.0.56 test/controllers/insights_sync/settings_controller_test.rb
foreman_rh_cloud-9.0.55 test/controllers/insights_sync/settings_controller_test.rb
foreman_rh_cloud-9.0.54 test/controllers/insights_sync/settings_controller_test.rb
foreman_rh_cloud-9.0.53 test/controllers/insights_sync/settings_controller_test.rb
foreman_rh_cloud-9.0.52 test/controllers/insights_sync/settings_controller_test.rb
foreman_rh_cloud-8.0.52 test/controllers/insights_sync/settings_controller_test.rb
foreman_rh_cloud-9.0.51 test/controllers/insights_sync/settings_controller_test.rb
foreman_rh_cloud-8.0.51 test/controllers/insights_sync/settings_controller_test.rb
foreman_rh_cloud-7.0.48 test/controllers/insights_sync/settings_controller_test.rb
foreman_rh_cloud-7.0.47 test/controllers/insights_sync/settings_controller_test.rb