summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-07-06 15:25:54 +0000
committerDouwe Maan <douwe@gitlab.com>2016-07-06 15:25:54 +0000
commitb5b17d00eddef8011e3a71d5f4ad46c6d40cbf8a (patch)
treee1fe97b1c34be156f1b29a0013273f886c859a83 /spec/models
parent0742b65203019cd1164bc8eb7c357439861d91b6 (diff)
parent19e15ae244776d4d148e6a65a1443f94bb59398c (diff)
downloadgitlab-ce-b5b17d00eddef8011e3a71d5f4ad46c6d40cbf8a.tar.gz
Merge branch '19092-fix-event-for-legacydiffnote-not-considered-note' into 'master'
Fix diff comments not showing up in activity feed ## What does this MR do? It fixes the detection of note events to check for `Note` and `LegacyDiffNote`. ## Are there points in the code the reviewer needs to double check? No? /cc @DouweM (since I believe you introduced `LegacyDiffNote` ## Why was this MR needed? To fix #19092. ## What are the relevant issue numbers? Fixes #19092. ## Does this MR meet the acceptance criteria? - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - Tests - [x] Added for this feature/bug - [ ] All builds are passing - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !5069
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/event_spec.rb32
1 files changed, 31 insertions, 1 deletions
diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb
index 166a1dc4ddb..6ac19756f15 100644
--- a/spec/models/event_spec.rb
+++ b/spec/models/event_spec.rb
@@ -46,6 +46,22 @@ describe Event, models: true do
it { expect(@event.author).to eq(@user) }
end
+ describe '#note?' do
+ subject { Event.new(project: target.project, target: target) }
+
+ context 'issue note event' do
+ let(:target) { create(:note_on_issue) }
+
+ it { is_expected.to be_note }
+ end
+
+ context 'merge request diff note event' do
+ let(:target) { create(:note_on_merge_request_diff) }
+
+ it { is_expected.to be_note }
+ end
+ end
+
describe '#visible_to_user?' do
let(:project) { create(:empty_project, :public) }
let(:non_member) { create(:user) }
@@ -89,7 +105,7 @@ describe Event, models: true do
end
end
- context 'note event' do
+ context 'issue note event' do
context 'on non confidential issues' do
let(:target) { note_on_issue }
@@ -112,6 +128,20 @@ describe Event, models: true do
it { expect(event.visible_to_user?(admin)).to eq true }
end
end
+
+ context 'merge request diff note event' do
+ let(:project) { create(:project, :public) }
+ let(:merge_request) { create(:merge_request, source_project: project, author: author, assignee: assignee) }
+ let(:note_on_merge_request) { create(:note_on_merge_request_diff, noteable: merge_request, project: project) }
+ let(:target) { note_on_merge_request }
+
+ it { expect(event.visible_to_user?(non_member)).to eq true }
+ it { expect(event.visible_to_user?(author)).to eq true }
+ it { expect(event.visible_to_user?(assignee)).to eq true }
+ it { expect(event.visible_to_user?(member)).to eq true }
+ it { expect(event.visible_to_user?(guest)).to eq true }
+ it { expect(event.visible_to_user?(admin)).to eq true }
+ end
end
describe '.limit_recent' do