diff options
author | Shinya Maeda <shinya@gitlab.com> | 2019-04-29 14:29:54 +0700 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2019-04-30 10:14:19 +0700 |
commit | 96b28d8387b97afae5a77eb6a4b240b67b1ced7f (patch) | |
tree | 3fb6882e8927e19cfeac866136cdc8157c22b4a1 /spec/presenters | |
parent | f109d24ddca8d15c315d0283dd54e0be44ce2c42 (diff) | |
download | gitlab-ce-96b28d8387b97afae5a77eb6a4b240b67b1ced7f.tar.gz |
Fix ref_text of merge request pipelinesfix-ref-text-of-mr-pipelines
Source branch can be removed after the merge and
we have to make sure to avoid rendering links if it's the case.
Diffstat (limited to 'spec/presenters')
-rw-r--r-- | spec/presenters/merge_request_presenter_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/presenters/merge_request_presenter_spec.rb b/spec/presenters/merge_request_presenter_spec.rb index e5f08aeb1fa..451dc88880c 100644 --- a/spec/presenters/merge_request_presenter_spec.rb +++ b/spec/presenters/merge_request_presenter_spec.rb @@ -439,6 +439,52 @@ describe MergeRequestPresenter do end end + describe '#source_branch_link' do + subject { presenter.source_branch_link } + + let(:presenter) { described_class.new(resource, current_user: user) } + + context 'when source branch exists' do + it 'returns link' do + allow(resource).to receive(:source_branch_exists?) { true } + + is_expected + .to eq("<a class=\"ref-name\" href=\"#{presenter.source_branch_commits_path}\">#{presenter.source_branch}</a>") + end + end + + context 'when source branch does not exist' do + it 'returns text' do + allow(resource).to receive(:source_branch_exists?) { false } + + is_expected.to eq("<span class=\"ref-name\">#{presenter.source_branch}</span>") + end + end + end + + describe '#target_branch_link' do + subject { presenter.target_branch_link } + + let(:presenter) { described_class.new(resource, current_user: user) } + + context 'when target branch exists' do + it 'returns link' do + allow(resource).to receive(:target_branch_exists?) { true } + + is_expected + .to eq("<a class=\"ref-name\" href=\"#{presenter.target_branch_commits_path}\">#{presenter.target_branch}</a>") + end + end + + context 'when target branch does not exist' do + it 'returns text' do + allow(resource).to receive(:target_branch_exists?) { false } + + is_expected.to eq("<span class=\"ref-name\">#{presenter.target_branch}</span>") + end + end + end + describe '#source_branch_with_namespace_link' do subject do described_class.new(resource, current_user: user).source_branch_with_namespace_link |