Sha256: 33043c8708eeb5ac663e4acbd76c381326ecb865eb5704287a9765bcd28cb862

Contents?: true

Size: 976 Bytes

Versions: 11

Compression:

Stored size: 976 Bytes

Contents

require_relative '../../../test_plugin_helper'

class Api::V2::SettingsControllerTest < ActionController::TestCase
  setup do
    FactoryBot.create(:setting, :name => 'discovery_prefix', :value => 'mac', :category => 'Setting::Discovered')
  end

  test_attributes :pid => '2c5ecb7e-87bc-4980-9620-7ae00e3f360e'
  test "should not update hostname prefix without value" do
    setting = Setting.find_by_name("discovery_prefix")
    put :update, params: { :id => setting.id, :setting => { :value => '' } }
    assert_nil JSON.parse(@response.body)['value']
  end

  test_attributes :pid => '4969994d-f934-4f0e-9a98-476b87eb0527'
  test "should update hostname prefix" do
    value = RFauxFactory.gen_alpha
    setting = Setting.find_by_name("discovery_prefix")
    put :update, params: { :id => setting.id, :setting => { :value => value } }
    assert_equal JSON.parse(@response.body)['value'], value, "Can't update discovery_prefix setting with valid value #{value}"
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
foreman_discovery-17.0.5 test/functional/api/v2/settings_controller_test.rb
foreman_discovery-17.0.4 test/functional/api/v2/settings_controller_test.rb
foreman_discovery-17.0.3 test/functional/api/v2/settings_controller_test.rb
foreman_discovery-17.0.2 test/functional/api/v2/settings_controller_test.rb
foreman_discovery-17.0.1 test/functional/api/v2/settings_controller_test.rb
foreman_discovery-16.3.6 test/functional/api/v2/settings_controller_test.rb
foreman_discovery-17.0.0 test/functional/api/v2/settings_controller_test.rb
foreman_discovery-16.3.5 test/functional/api/v2/settings_controller_test.rb
foreman_discovery-16.3.4 test/functional/api/v2/settings_controller_test.rb
foreman_discovery-16.3.1 test/functional/api/v2/settings_controller_test.rb
foreman_discovery-16.2.0 test/functional/api/v2/settings_controller_test.rb