diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-08 12:06:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-08 12:06:09 +0300 |
commit | 77a7772c3bdb03d92cbc154f6b1a762953cc7c19 (patch) | |
tree | b841c2233afb01d1b6cc7dd4023f2b677ec19eb3 /spec/presenters | |
parent | f7234a0894db99c7ade3cf29c1b467aa4807cc41 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/presenters')
-rw-r--r-- | spec/presenters/ci/pipeline_presenter_spec.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/presenters/ci/pipeline_presenter_spec.rb b/spec/presenters/ci/pipeline_presenter_spec.rb index 7e8bbedcf6d..8cfcd9befb3 100644 --- a/spec/presenters/ci/pipeline_presenter_spec.rb +++ b/spec/presenters/ci/pipeline_presenter_spec.rb @@ -176,6 +176,44 @@ describe Ci::PipelinePresenter do end end + describe '#all_related_merge_request_text' do + subject { presenter.all_related_merge_request_text } + + context 'with zero related merge requests (branch pipeline)' do + it { is_expected.to eq('No related merge requests found.') } + end + + context 'with one related merge request' do + let!(:mr_1) { create(:merge_request, project: project, source_project: project) } + + it { + is_expected.to eq("1 related merge request: " \ + "<a class=\"mr-iid\" href=\"#{merge_request_path(mr_1)}\">#{mr_1.to_reference} #{mr_1.title}</a>") + } + end + + context 'with two related merge requests' do + let!(:mr_1) { create(:merge_request, project: project, source_project: project, target_branch: 'staging') } + let!(:mr_2) { create(:merge_request, project: project, source_project: project, target_branch: 'feature') } + + it { + is_expected.to eq("2 related merge requests: " \ + "<a class=\"mr-iid\" href=\"#{merge_request_path(mr_2)}\">#{mr_2.to_reference} #{mr_2.title}</a>, " \ + "<a class=\"mr-iid\" href=\"#{merge_request_path(mr_1)}\">#{mr_1.to_reference} #{mr_1.title}</a>") + } + end + end + + describe '#all_related_merge_requests' do + it 'memoizes the returned relation' do + query_count = ActiveRecord::QueryRecorder.new do + 2.times { presenter.send(:all_related_merge_requests).count } + end.count + + expect(query_count).to eq(1) + end + end + describe '#link_to_merge_request' do subject { presenter.link_to_merge_request } |