diff options
Diffstat (limited to 'spec/policies/note_policy_spec.rb')
-rw-r--r-- | spec/policies/note_policy_spec.rb | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/spec/policies/note_policy_spec.rb b/spec/policies/note_policy_spec.rb index 5aee66275d4..2619bb2fe3c 100644 --- a/spec/policies/note_policy_spec.rb +++ b/spec/policies/note_policy_spec.rb @@ -54,6 +54,27 @@ describe NotePolicy do end end + context 'when the noteable is a personal snippet' do + let(:noteable) { create(:personal_snippet, :public) } + let(:note) { create(:note, noteable: noteable, author: user) } + + it 'can edit note' do + expect(policy).to be_allowed(:admin_note) + expect(policy).to be_allowed(:resolve_note) + expect(policy).to be_allowed(:read_note) + end + + context 'when it is private' do + let(:noteable) { create(:personal_snippet, :private) } + + it 'can not edit nor read the note' do + expect(policy).to be_disallowed(:admin_note) + expect(policy).to be_disallowed(:resolve_note) + expect(policy).to be_disallowed(:read_note) + end + end + end + context 'when the project is public' do context 'when the note author is not a project member' do it 'can edit a note' do @@ -79,26 +100,6 @@ describe NotePolicy do end end - context 'when the noteable is a personal snippet' do - let(:noteable) { create(:personal_snippet, :public) } - - it 'can edit note' do - expect(policy).to be_allowed(:admin_note) - expect(policy).to be_allowed(:resolve_note) - expect(policy).to be_allowed(:read_note) - end - - context 'when it is private' do - let(:noteable) { create(:personal_snippet, :private) } - - it 'can not edit nor read the note' do - expect(policy).to be_disallowed(:admin_note) - expect(policy).to be_disallowed(:resolve_note) - expect(policy).to be_disallowed(:read_note) - end - end - end - context 'when a discussion is confidential' do before do issue.update_attribute(:confidential, true) |