Sha256: aab2730dd095171579eed99628a9906b2ac33b2e28955e72b810178615f8e689

Contents?: true

Size: 1.24 KB

Versions: 22

Compression:

Stored size: 1.24 KB

Contents

require File.join(File.dirname(__FILE__), '../test_helper')

describe HammerCLIForeman::OptionSources::IdsParams do
  describe "get_options" do
    class IdsParamsTestCommand < HammerCLIForeman::CreateCommand
      resource :users
      build_options
    end

    let(:cmd) { IdsParamsTestCommand.new("", { :adapter => :csv, :interactive => false }) }
    let(:ids_params_source) { HammerCLIForeman::OptionSources::IdsParams.new(cmd) }

    it "skips param when set" do
      cmd.stubs(:get_resource_ids).returns(nil)
      cmd.expects(:get_resource_ids).with { |res| res.name == :locations }.never
      option_data = { 'option_location_ids' => [3], 'option_location_names' => 'test' }
      params = ids_params_source.get_options([], option_data)
      _(params).must_equal option_data
    end

    it "resolves param when unset" do
      cmd.stubs(:get_resource_ids).returns(nil)
      cmd.expects(:get_resource_ids).with { |res| res.name == :locations }.returns([1])
      option_data = { 'option_location_ids' => nil, 'option_location_names' => 'test' }
      expected_data = { 'option_location_ids' => [1], 'option_location_names' => 'test' }
      params = ids_params_source.get_options([], option_data)
      _(params).must_equal expected_data
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
hammer_cli_foreman-3.14.0 test/unit/option_sources/ids_params_test.rb
hammer_cli_foreman-3.13.0 test/unit/option_sources/ids_params_test.rb
hammer_cli_foreman-3.12.0 test/unit/option_sources/ids_params_test.rb
hammer_cli_foreman-3.10.0 test/unit/option_sources/ids_params_test.rb
hammer_cli_foreman-3.9.0 test/unit/option_sources/ids_params_test.rb
hammer_cli_foreman-3.8.0 test/unit/option_sources/ids_params_test.rb
hammer_cli_foreman-3.7.0 test/unit/option_sources/ids_params_test.rb
hammer_cli_foreman-3.5.1 test/unit/option_sources/ids_params_test.rb
hammer_cli_foreman-3.6.0 test/unit/option_sources/ids_params_test.rb
hammer_cli_foreman-3.5.0 test/unit/option_sources/ids_params_test.rb
hammer_cli_foreman-3.4.0 test/unit/option_sources/ids_params_test.rb
hammer_cli_foreman-3.3.0 test/unit/option_sources/ids_params_test.rb
hammer_cli_foreman-3.2.0 test/unit/option_sources/ids_params_test.rb
hammer_cli_foreman-2.5.2 test/unit/option_sources/ids_params_test.rb
hammer_cli_foreman-3.1.0 test/unit/option_sources/ids_params_test.rb
hammer_cli_foreman-2.5.1 test/unit/option_sources/ids_params_test.rb
hammer_cli_foreman-2.5.0 test/unit/option_sources/ids_params_test.rb
hammer_cli_foreman-2.3.2 test/unit/option_sources/ids_params_test.rb
hammer_cli_foreman-2.4.0 test/unit/option_sources/ids_params_test.rb
hammer_cli_foreman-2.3.1 test/unit/option_sources/ids_params_test.rb