summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-06-20 15:18:51 -0700
committerStan Hu <stanhu@gmail.com>2019-06-20 15:59:41 -0700
commit1b7ab11f9489690149f7ff1b78a927e5b3bbcfe0 (patch)
tree21d761c3baf2c37021c67b753e475be266b9aae8 /spec
parent61a2ed5d0ec945e17f10b01c3eb1fc9e22c87bb1 (diff)
downloadgitlab-ce-1b7ab11f9489690149f7ff1b78a927e5b3bbcfe0.tar.gz
Omit issues links in merge request entity API response
The merge request widget has a section that includes which issues may be closed or mentioned based on the merge request description. The problem is that rendering and redacting Markdown can be expensive, especially since the browser polls for the data every 10 seconds. Since these links don't change much and are just nice to have, we only load them on first page load. The frontend will use the existing data if the data doesn't appear on subsequent requests. This saves about 30% of the rendering time of this endpoint, which adds up to significant savings considering that `MergeRequestsController#show.json` is called over a million times a day on GitLab.com. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/63546
Diffstat (limited to 'spec')
-rw-r--r--spec/serializers/merge_request_widget_entity_spec.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/serializers/merge_request_widget_entity_spec.rb b/spec/serializers/merge_request_widget_entity_spec.rb
index a27c22191f4..ffbfac9b326 100644
--- a/spec/serializers/merge_request_widget_entity_spec.rb
+++ b/spec/serializers/merge_request_widget_entity_spec.rb
@@ -32,6 +32,19 @@ describe MergeRequestWidgetEntity do
end
end
+ describe 'issues links' do
+ it 'includes issues links when requested' do
+ data = described_class.new(resource, request: request, issues_links: true).as_json
+
+ expect(data).to include(:issues_links)
+ expect(data[:issues_links]).to include(:assign_to_closing, :closing, :mentioned_but_not_closing)
+ end
+
+ it 'omits issue links by default' do
+ expect(subject).not_to include(:issues_links)
+ end
+ end
+
describe 'pipeline' do
let(:pipeline) { create(:ci_empty_pipeline, project: project, ref: resource.source_branch, sha: resource.source_branch_sha, head_pipeline_of: resource) }