debian-mirror-gitlab/spec/lib/gitlab/allowable_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
724 B
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::Allowable do
2017-08-17 22:00:37 +05:30
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-09-10 17:25:29 +05:30
let(:project) { create(:project, :public) }
2017-08-17 22:00:37 +05:30
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-09-10 17:25:29 +05:30
let(:project) { create(:project, :private) }
2017-08-17 22:00:37 +05:30
it 'reports correct ability to perform action' do
expect(subject.can?(user, :read_project, project)).to be false
end
end
end
end