diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-12-13 14:44:43 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-12-13 14:44:43 +0100 |
commit | 00970606d78486a8b6672659e9ea28521a102e44 (patch) | |
tree | 2b41f3344f9d894a75f87bda627eda911199722f /spec/lib/gitlab/allowable_spec.rb | |
parent | 24dd70d37834e55a7ead23ae14125e5e12f64d8b (diff) | |
download | gitlab-ce-00970606d78486a8b6672659e9ea28521a102e44.tar.gz |
Extract abilities checking module from ability model
Diffstat (limited to 'spec/lib/gitlab/allowable_spec.rb')
-rw-r--r-- | spec/lib/gitlab/allowable_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/lib/gitlab/allowable_spec.rb b/spec/lib/gitlab/allowable_spec.rb new file mode 100644 index 00000000000..87733d53e92 --- /dev/null +++ b/spec/lib/gitlab/allowable_spec.rb @@ -0,0 +1,27 @@ +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 + let(:project) { create(:empty_project, :public) } + + 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 + let(:project) { create(:empty_project, :private) } + + it 'reports correct ability to perform action' do + expect(subject.can?(user, :read_project, project)).to be false + end + end + end +end |