Sha256: 5413e049f5e94847239d3d349eafdeb9833bd6e7bdf48f605ff07d11c88969c0

Contents?: true

Size: 1.2 KB

Versions: 18

Compression:

Stored size: 1.2 KB

Contents

require 'test_plugin_helper'

class JobTemplateEffectiveUserTest < ActiveSupport::TestCase
  let(:job_template) { FactoryBot.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 = FactoryBot.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

18 entries across 18 versions & 1 rubygems

Version Path
foreman_remote_execution-1.6.5 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.6.4 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.5.6 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.6.3 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.6.2 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.5.5 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.6.1 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.6.0 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.5.4 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.5.3 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.5.2 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.5.1 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.5.0 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.4.6 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.4.5 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.4.4 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.4.3 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-1.4.2 test/unit/job_template_effective_user_test.rb