debian-mirror-gitlab/spec/policies/base_policy_spec.rb

20 lines
579 B
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe BasePolicy do
2017-08-17 22:00:37 +05:30
describe '.class_for' do
it 'detects policy class based on the subject ancestors' do
2017-09-10 17:25:29 +05:30
expect(DeclarativePolicy.class_for(GenericCommitStatus.new)).to eq(CommitStatusPolicy)
2017-08-17 22:00:37 +05:30
end
it 'detects policy class for a presented subject' do
presentee = Ci::BuildPresenter.new(Ci::Build.new)
2017-09-10 17:25:29 +05:30
expect(DeclarativePolicy.class_for(presentee)).to eq(Ci::BuildPolicy)
2017-08-17 22:00:37 +05:30
end
it 'uses GlobalPolicy when :global is given' do
2017-09-10 17:25:29 +05:30
expect(DeclarativePolicy.class_for(:global)).to eq(GlobalPolicy)
2017-08-17 22:00:37 +05:30
end
end
end