2017-01-09 15:43:15 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe BasePolicy, models: true do
|
2017-01-10 17:41:04 -05:00
|
|
|
let(:build) { Ci::Build.new }
|
2017-01-09 15:43:15 -05:00
|
|
|
|
|
|
|
describe '.class_for' do
|
|
|
|
it 'detects policy class based on the subject ancestors' do
|
|
|
|
expect(described_class.class_for(build)).to eq(Ci::BuildPolicy)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'detects policy class for a presented subject' do
|
2017-01-10 17:41:04 -05:00
|
|
|
presentee = Ci::BuildPresenter.new(build)
|
2017-01-09 15:43:15 -05:00
|
|
|
|
|
|
|
expect(described_class.class_for(presentee)).to eq(Ci::BuildPolicy)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|