Commit 275a46c5 authored by http://jneen.net/'s avatar http://jneen.net/

spec the new behavior of .class_for

and more robustly spec the ancestor behavior
parent f1d3a92b
require 'spec_helper' require 'spec_helper'
describe BasePolicy, models: true do describe BasePolicy, models: true do
let(:build) { Ci::Build.new }
describe '.class_for' do describe '.class_for' do
it 'detects policy class based on the subject ancestors' do it 'detects policy class based on the subject ancestors' do
expect(described_class.class_for(build)).to eq(Ci::BuildPolicy) expect(described_class.class_for(GenericCommitStatus.new)).to eq(CommitStatusPolicy)
end end
it 'detects policy class for a presented subject' do it 'detects policy class for a presented subject' do
presentee = Ci::BuildPresenter.new(build) presentee = Ci::BuildPresenter.new(Ci::Build.new)
expect(described_class.class_for(presentee)).to eq(Ci::BuildPolicy) expect(described_class.class_for(presentee)).to eq(Ci::BuildPolicy)
end end
it 'uses GlobalPolicy when :global is given' do
expect(described_class.class_for(:global)).to eq(GlobalPolicy)
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment