summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/finders/finder_with_external_authorization_enabled.rb
blob: d7e17cc0b7008a4faec511abd2391456ed315b76 (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
require 'spec_helper'

shared_examples 'a finder with external authorization service' do
  include ExternalAuthorizationServiceHelpers

  let(:user) { create(:user) }
  let(:project) { create(:project) }

  before do
    project.add_maintainer(user)
  end

  it 'finds the subject' do
    expect(described_class.new(user).execute).to include(subject)
  end

  context 'with an external authorization service' do
    before do
      enable_external_authorization_service_check
    end

    it 'does not include the subject when no project was given' do
      expect(described_class.new(user).execute).not_to include(subject)
    end

    it 'includes the subject when a project id was given' do
      expect(described_class.new(user, project_params).execute).to include(subject)
    end
  end
end