diff options
author | Jarka Kadlecova <jarka@gitlab.com> | 2017-01-05 16:36:06 +0300 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-01-19 02:38:17 +0300 |
commit | d6b11dafd37e78c12c982c42f274928293cdfa53 (patch) | |
tree | e20c62bc3b11b77e366bce2251146d5f5ec86e0c /spec/models/ability_spec.rb | |
parent | 270dc22658424ee7f279db99e56c6fc69acd3eb7 (diff) |
Support notes without project
Diffstat (limited to 'spec/models/ability_spec.rb')
-rw-r--r-- | spec/models/ability_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index 1bdf005c823..0b138405f02 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -171,6 +171,36 @@ describe Ability, lib: true do end end + describe '.users_that_can_read_personal_snippet' do + subject { Ability.users_that_can_read_personal_snippet(users, snippet) } + let(:users) { create_list(:user, 3) } + let(:author) { users[0] } + + context 'private snippet' do + let(:snippet) { create(:personal_snippet, :private, author: author) } + + it 'is readable only by its author' do + expect(subject).to match_array([author]) + end + end + + context 'internal snippet' do + let(:snippet) { create(:personal_snippet, :public, author: author) } + + it 'is readable by all registered users' do + expect(subject).to match_array(users) + end + end + + context 'public snippet' do + let(:snippet) { create(:personal_snippet, :public, author: author) } + + it 'is readable by all users' do + expect(subject).to match_array(users) + end + end + end + describe '.issues_readable_by_user' do context 'with an admin user' do it 'returns all given issues' do |