Sha256: 4e2b4cccf765690a46134fbd23853e20e0a0d11ebade5808cf106a150f59d3c0

Contents?: true

Size: 1.16 KB

Versions: 20

Compression:

Stored size: 1.16 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 }

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

    it 'does not use the current user' do
      assert_not 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
      assert_equal user.login, effective_user.compute_value
    end

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

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
foreman_remote_execution-13.2.8 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-15.0.2 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-15.0.1 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-13.2.7 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-15.0.0 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-14.1.4 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-14.1.3 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-14.1.2 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-14.1.1 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-14.0.2 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-14.0.1 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-13.2.6 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-14.0.0 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-13.2.5 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-13.2.4 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-13.2.3 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-13.2.2 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-13.2.1 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-13.2.0 test/unit/job_template_effective_user_test.rb
foreman_remote_execution-13.0.0 test/unit/job_template_effective_user_test.rb