summaryrefslogtreecommitdiff
path: root/spec/models/note_spec.rb
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2016-05-26 14:12:43 +0300
committerValery Sizov <valery@gitlab.com>2016-05-27 19:58:31 +0300
commite90df69859a31b9a24a401a8cc6b3c7aea2fb65c (patch)
tree7ddda681c2869a52038e3b72a05de6715c700581 /spec/models/note_spec.rb
parentf2caad2467f318ec1359ee9b03509e831cde9d16 (diff)
downloadgitlab-ce-data_leak.tar.gz
Confidential notes data leakdata_leak
Diffstat (limited to 'spec/models/note_spec.rb')
-rw-r--r--spec/models/note_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
index 5d916f0e6a6..427c7a3ed6f 100644
--- a/spec/models/note_spec.rb
+++ b/spec/models/note_spec.rb
@@ -111,6 +111,25 @@ describe Note, models: true do
it 'returns notes with matching content regardless of the casing' do
expect(described_class.search('WOW')).to eq([note])
end
+
+ context "confidential issues" do
+ let(:user) { create :user }
+ let(:confidential_issue) { create :issue, confidential: true, author: user }
+ let(:confidential_note) { create :note, note: "Random", noteable: confidential_issue }
+
+ it "returns notes with matching content if user can see the issue" do
+ expect(described_class.search(confidential_note.note, user)).to eq([confidential_note])
+ end
+
+ it "does not return notes with matching content if user can not see the issue" do
+ user = create :user
+ expect(described_class.search(confidential_note.note, user)).to be_empty
+ end
+
+ it "does not return notes with matching content for unauthenticated users" do
+ expect(described_class.search(confidential_note.note)).to be_empty
+ end
+ end
end
describe '.grouped_awards' do