diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-07-12 00:29:12 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-07-12 00:29:12 +0000 |
commit | 774ff17804c879c3445c350de510204676330be9 (patch) | |
tree | f05fe6b3f1a73cc4eb4010653301307dc141e1c0 /spec/features | |
parent | 8ef930c41a4c5ccb8b99a62a663c594fa0f0a726 (diff) | |
parent | af3727b34a3e61668ffca8dc4db85e3c57ff2cc8 (diff) | |
download | gitlab-ce-774ff17804c879c3445c350de510204676330be9.tar.gz |
Merge branch 'optimize-cross-ref-system-notes-check' into 'master'
Optimize cross ref system notes check
## What does this MR do?
This MR optimizes system note visibility checking by memoizing the visible reference count, reducing the overhead of calling `Note#cross_reference_not_visible_for?`.
## Are there points in the code the reviewer needs to double check?
Note that since a cross reference message contains, "Mentioned in XYZ", we EXPECT that there is at least one reference. That's why using the ref count > 0 works.
## Why was this MR needed?
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. This shaves about 0.8 s
from the load time from https://gitlab.com/gitlab-com/operations/issues/42.
## What are the relevant issue numbers?
#19273
## Screenshots (if relevant)
## Does this MR meet the acceptance criteria?
- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [ ] API support added
- Tests
- [x] Added for this feature/bug
- [x] 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 !5070
Diffstat (limited to 'spec/features')
-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 dd016a36d1e..0b38c413f44 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 } |