2019-07-25 01:21:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-13 08:44:43 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Gitlab::Allowable do
|
|
|
|
subject do
|
|
|
|
Class.new.include(described_class).new
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#can?' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
context 'when user is allowed to do something' do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, :public) }
|
2016-12-13 08:44:43 -05:00
|
|
|
|
|
|
|
it 'reports correct ability to perform action' do
|
|
|
|
expect(subject.can?(user, :read_project, project)).to be true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user is not allowed to do something' do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, :private) }
|
2016-12-13 08:44:43 -05:00
|
|
|
|
|
|
|
it 'reports correct ability to perform action' do
|
|
|
|
expect(subject.can?(user, :read_project, project)).to be false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|