diff options
Diffstat (limited to 'spec/presenters/ci/pipeline_presenter_spec.rb')
-rw-r--r-- | spec/presenters/ci/pipeline_presenter_spec.rb | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/spec/presenters/ci/pipeline_presenter_spec.rb b/spec/presenters/ci/pipeline_presenter_spec.rb index cc68cdff7c1..fc13b377014 100644 --- a/spec/presenters/ci/pipeline_presenter_spec.rb +++ b/spec/presenters/ci/pipeline_presenter_spec.rb @@ -146,69 +146,6 @@ RSpec.describe Ci::PipelinePresenter do end end - describe '#ref_text_legacy' do - subject { presenter.ref_text_legacy } - - context 'when pipeline is detached merge request pipeline' do - let(:merge_request) { create(:merge_request, :with_detached_merge_request_pipeline) } - let(:pipeline) { merge_request.all_pipelines.last } - - it 'returns a correct ref text' do - is_expected.to eq("for <a class=\"mr-iid\" href=\"#{project_merge_request_path(merge_request.project, merge_request)}\">#{merge_request.to_reference}</a> " \ - "with <a class=\"ref-name gl-link gl-bg-blue-50 gl-rounded-base gl-px-2\" href=\"#{project_commits_path(merge_request.source_project, merge_request.source_branch)}\">#{merge_request.source_branch}</a>") - end - end - - context 'when pipeline is merge request pipeline' do - let(:merge_request) { create(:merge_request, :with_merge_request_pipeline) } - let(:pipeline) { merge_request.all_pipelines.last } - - it 'returns a correct ref text' do - is_expected.to eq("for <a class=\"mr-iid\" href=\"#{project_merge_request_path(merge_request.project, merge_request)}\">#{merge_request.to_reference}</a> " \ - "with <a class=\"ref-name gl-link gl-bg-blue-50 gl-rounded-base gl-px-2\" href=\"#{project_commits_path(merge_request.source_project, merge_request.source_branch)}\">#{merge_request.source_branch}</a> " \ - "into <a class=\"ref-name gl-link gl-bg-blue-50 gl-rounded-base gl-px-2\" href=\"#{project_commits_path(merge_request.target_project, merge_request.target_branch)}\">#{merge_request.target_branch}</a>") - end - end - - context 'when pipeline is branch pipeline' do - context 'when ref exists in the repository' do - before do - allow(pipeline).to receive(:ref_exists?) { true } - end - - it 'returns a correct ref text' do - is_expected.to eq("for <a class=\"ref-name gl-link gl-bg-blue-50 gl-rounded-base gl-px-2\" href=\"#{project_commits_path(pipeline.project, pipeline.ref)}\">#{pipeline.ref}</a>") - end - - context 'when ref contains malicious script' do - let(:pipeline) { create(:ci_pipeline, ref: "<script>alter('1')</script>", project: project) } - - it 'does not include the malicious script' do - is_expected.not_to include("<script>alter('1')</script>") - end - end - end - - context 'when ref does not exist in the repository' do - before do - allow(pipeline).to receive(:ref_exists?) { false } - end - - it 'returns a correct ref text' do - is_expected.to eq("for <span class=\"ref-name\">#{pipeline.ref}</span>") - end - - context 'when ref contains malicious script' do - let(:pipeline) { create(:ci_pipeline, ref: "<script>alter('1')</script>", project: project) } - - it 'does not include the malicious script' do - is_expected.not_to include("<script>alter('1')</script>") - end - end - end - end - end - describe '#ref_text' do subject { presenter.ref_text } @@ -272,49 +209,6 @@ RSpec.describe Ci::PipelinePresenter do end end - describe '#all_related_merge_request_text' do - subject { presenter.all_related_merge_request_text } - - let_it_be(:mr_1) { create(:merge_request) } - let_it_be(:mr_2) { create(:merge_request) } - - 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 - before do - allow(pipeline).to receive(:all_merge_requests).and_return(MergeRequest.where(id: mr_1.id)) - end - - 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 - before do - allow(pipeline).to receive(:all_merge_requests).and_return(MergeRequest.where(id: [mr_1.id, mr_2.id])) - end - - 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>") - } - - context 'with a limit passed' do - subject { presenter.all_related_merge_request_text(limit: 1) } - - 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>") - } - end - end - end - describe '#all_related_merge_requests' do subject(:all_related_merge_requests) do presenter.send(:all_related_merge_requests) |