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

abuse_report_policy_spec.rb « policies « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3cc92749ab405c23abfb85ae5dcdf4b961ae8c5e (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe AbuseReportPolicy, feature_category: :insider_threat do
  let(:abuse_report) { build_stubbed(:abuse_report) }

  subject(:policy) { described_class.new(user, abuse_report) }

  context 'when the user is not an admin' do
    let(:user) { create(:user) }

    it 'cannot read_abuse_report' do
      expect(policy).to be_disallowed(:read_abuse_report)
      expect(policy).to be_disallowed(:read_note)
      expect(policy).to be_disallowed(:create_note)
    end
  end

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

    it 'can read_abuse_report' do
      expect(policy).to be_allowed(:read_abuse_report)
      expect(policy).to be_allowed(:read_note)
      expect(policy).to be_allowed(:create_note)
    end
  end
end