Sha256: 581d6cc07c72357f9681d503d1e55231e4ca8ef91a2c431de9b34442d79112f7

Contents?: true

Size: 1.45 KB

Versions: 8

Compression:

Stored size: 1.45 KB

Contents

require 'test_puppet_helper'

module ForemanPuppet
  class UserTest < ActiveSupport::TestCase
    describe '#visible_environments' do
      let(:environment) { FactoryBot.create(:environment) }
      let(:untaxed_env) { FactoryBot.create(:environment, organizations: [], locations: []) }
      let(:env_names) do
        env_names = [environment.name, untaxed_env.name]
        env_names += %w[production global_puppetmaster testing] unless ForemanPuppet.extracted_from_core?
        env_names
      end

      setup do
        environment
        untaxed_env
      end

      # These will need refactor when the environment fixtures will be gone
      test 'should show the list of environments visible as admin user' do
        # Admin user sees all environments - including the ones without taxonomies\
        assert_equal env_names.sort, ::User.current.visible_environments.sort
      end

      test 'should show the list of environments visible as inherited admin user' do
        ::User.current = FactoryBot.create(:user, usergroups: [FactoryBot.create(:usergroup, admin: true)]).reload
        assert_same_elements env_names.sort, ::User.current.visible_environments
      end

      test 'should show the list of environments visible as non-admin user' do
        # Non-admin user only sees environments in a taxonomy at least
        setup_user 'view', 'environments'
        assert_equal [environment.name], ::User.current.visible_environments
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
foreman_puppet-1.0.5 test/models/foreman_puppet/user_test.rb
foreman_puppet-1.0.4 test/models/foreman_puppet/user_test.rb
foreman_puppet-1.0.3 test/models/foreman_puppet/user_test.rb
foreman_puppet-1.0.2 test/models/foreman_puppet/user_test.rb
foreman_puppet-1.0.1 test/models/foreman_puppet/user_test.rb
foreman_puppet-1.0.0 test/models/foreman_puppet/user_test.rb
foreman_puppet-1.0.0.rc.2 test/models/foreman_puppet/user_test.rb
foreman_puppet-1.0.0.rc.1 test/models/foreman_puppet/user_test.rb