diff options
author | Stan Hu <stanhu@gmail.com> | 2016-07-04 08:31:43 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-07-12 01:09:21 +0300 |
commit | af3727b34a3e61668ffca8dc4db85e3c57ff2cc8 (patch) | |
tree | 0bcdece17af6a14e7e5793f7204ca29a34fc535f /spec/features/notes_on_merge_requests_spec.rb | |
parent | 734e44ee79590be6d9f01ca3e815304221a5c88d (diff) |
Optimize system note visibility checking by hiding notes that
have been fully redacted and contain cross-project references.
The previous implementation relied on Note#cross_reference_not_visible_for?,
which essentially tries to render all the Markdown references in a system note
and only displays the note if the user can see the referring project. But this
duplicated the work that Banzai::NotesRenderer was doing already. Instead, for
each note we render, we memoize the number of visible user references and
use it later if it is available.
Improves #19273
Diffstat (limited to 'spec/features/notes_on_merge_requests_spec.rb')
-rw-r--r-- | spec/features/notes_on_merge_requests_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/features/notes_on_merge_requests_spec.rb b/spec/features/notes_on_merge_requests_spec.rb index 5174168713c..64c6d9416f6 100644 --- a/spec/features/notes_on_merge_requests_spec.rb +++ b/spec/features/notes_on_merge_requests_spec.rb @@ -135,6 +135,28 @@ describe 'Comments', feature: true do end end + describe 'Handles cross-project system notes', js: true, feature: true do + let(:user) { create(:user) } + let(:project) { create(:project, :public) } + let(:project2) { create(:project, :private) } + let(:issue) { create(:issue, project: project2) } + let(:merge_request) { create(:merge_request, source_project: project, source_branch: 'markdown') } + let!(:note) { create(:note_on_merge_request, :system, noteable: merge_request, project: project, note: "mentioned in #{issue.to_reference(project)}") } + + it 'shows the system note' do + login_as :admin + visit namespace_project_merge_request_path(project.namespace, project, merge_request) + + expect(page).to have_css('.system-note') + end + + it 'hides redacted system note' do + visit namespace_project_merge_request_path(project.namespace, project, merge_request) + + expect(page).not_to have_css('.system-note') + end + end + describe 'On a merge request diff', js: true, feature: true do let(:merge_request) { create(:merge_request) } let(:project) { merge_request.source_project } |