summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/banzai/filters/inline_metrics_redactor_shared_examples.rb
blob: d283b3a3b277760c848c6422277b0fc28af1e5a5 (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
# frozen_string_literal: true

RSpec.shared_examples 'a supported metrics dashboard url' do
  context 'no user is logged in' do
    it 'redacts the placeholder' do
      expect(doc.to_s).to be_empty
    end
  end

  context 'the user does not have permission do see charts' do
    let(:doc) { filter(input, current_user: build(:user)) }

    it 'redacts the placeholder' do
      expect(doc.to_s).to be_empty
    end
  end

  context 'the user has requisite permissions' do
    let(:user) { create(:user) }
    let(:doc) { filter(input, current_user: user) }

    it 'leaves the placeholder' do
      project.add_maintainer(user)

      expect(doc.to_s).to eq(input)
    end
  end
end