Welcome to mirror list, hosted at ThFree Co, Russian Federation.

organization_policy_spec.rb « organizations « policies « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e51362227c9e2e3d9967c07ac6c2330fda609287 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Organizations::OrganizationPolicy, feature_category: :cell do
  let_it_be(:organization) { create(:organization) }

  subject(:policy) { described_class.new(current_user, organization) }

  context 'when the user is anonymous' do
    let_it_be(:current_user) { nil }

    it { is_expected.to be_allowed(:read_organization) }
  end

  context 'when the user is an admin' do
    let_it_be(:current_user) { create(:user, :admin) }

    context 'when admin mode is enabled', :enable_admin_mode do
      it { is_expected.to be_allowed(:admin_organization) }
      it { is_expected.to be_allowed(:read_organization) }
    end

    context 'when admin mode is disabled' do
      it { is_expected.to be_disallowed(:admin_organization) }
      it { is_expected.to be_allowed(:read_organization) }
    end
  end

  context 'when the user is an organization user' do
    let_it_be(:current_user) { create :user }

    before do
      create :organization_user, organization: organization, user: current_user
    end

    it { is_expected.to be_allowed(:read_organization) }
  end
end