BigW Consortium Gitlab

base_policy_spec.rb 587 Bytes
Newer Older
1 2 3 4 5
require 'spec_helper'

describe BasePolicy, models: true do
  describe '.class_for' do
    it 'detects policy class based on the subject ancestors' do
6
      expect(described_class.class_for(GenericCommitStatus.new)).to eq(CommitStatusPolicy)
7 8 9
    end

    it 'detects policy class for a presented subject' do
10
      presentee = Ci::BuildPresenter.new(Ci::Build.new)
11 12 13

      expect(described_class.class_for(presentee)).to eq(Ci::BuildPolicy)
    end
14 15 16 17

    it 'uses GlobalPolicy when :global is given' do
      expect(described_class.class_for(:global)).to eq(GlobalPolicy)
    end
18 19
  end
end