Sha256: 34cf258cd4f9dfe31e5524f11080a0d6d553b73c9437fa82d3f4d9e9cb7992c7

Contents?: true

Size: 1.18 KB

Versions: 13

Compression:

Stored size: 1.18 KB

Contents

require 'test_plugin_helper'

describe JobTemplateEffectiveUser do
  let(:job_template) { FactoryGirl.build(:job_template, :job_category => '') }
  let(:effective_user) { job_template.effective_user }

  before do
    Setting::RemoteExecution.load_defaults
  end

  describe 'by default' do
    it 'is overridable' do
      assert effective_user.overridable?
    end

    it 'does not use the current user' do
      refute effective_user.current_user?
    end
  end

  describe 'compute value' do
    it 'computes the value based on the current user when current_user set to true' do
      user = FactoryGirl.create(:user)
      User.current = user
      effective_user.current_user = true
      effective_user.compute_value.must_equal user.login
    end

    it 'returns the value when not current user is set to true' do
      effective_user.current_user = false
      effective_user.value = 'testuser'
      effective_user.compute_value.must_equal 'testuser'
    end

    it 'returns a default value when no value is specified for the user' do
      effective_user.value = ''
      Setting[:remote_execution_effective_user] = 'myuser'
      effective_user.compute_value.must_equal 'myuser'
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
foreman_remote_execution-1.3.0 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.2.2 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.2.1 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.2.0 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.1.1 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.1.0 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.0.0 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-0.3.2 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-0.3.1 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-0.3.0 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-0.2.3 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-0.2.2 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-0.2.1 test/unit/job_template_effective_user_test.rb