gitlab-org--gitlab-foss/spec/policies/base_policy_spec.rb
http://jneen.net/ 275a46c523 spec the new behavior of .class_for
and more robustly spec the ancestor behavior
2017-03-09 11:49:53 -08:00

19 lines
587 B
Ruby

require 'spec_helper'
describe BasePolicy, models: true do
describe '.class_for' do
it 'detects policy class based on the subject ancestors' do
expect(described_class.class_for(GenericCommitStatus.new)).to eq(CommitStatusPolicy)
end
it 'detects policy class for a presented subject' do
presentee = Ci::BuildPresenter.new(Ci::Build.new)
expect(described_class.class_for(presentee)).to eq(Ci::BuildPolicy)
end
it 'uses GlobalPolicy when :global is given' do
expect(described_class.class_for(:global)).to eq(GlobalPolicy)
end
end
end