summaryrefslogtreecommitdiff
path: root/spec/policies/identity_provider_policy_spec.rb
blob: f6b4e15cff91f95880dcba34db5b88e599e0f77d (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe IdentityProviderPolicy do
  subject(:policy) { described_class.new(user, provider) }

  let(:user) { User.new }
  let(:provider) { :a_provider }

  describe '#rules' do
    it { is_expected.to be_allowed(:link) }
    it { is_expected.to be_allowed(:unlink) }

    context 'when user is anonymous' do
      let(:user) { nil }

      it { is_expected.not_to be_allowed(:link) }
      it { is_expected.not_to be_allowed(:unlink) }
    end

    %w[saml cas3].each do |provider_name|
      context "when provider is #{provider_name}" do
        let(:provider) { provider_name }

        it { is_expected.to be_allowed(:link) }
        it { is_expected.not_to be_allowed(:unlink) }
      end
    end
  end
end