diff options
author | drew cimino <dcimino@gitlab.com> | 2019-04-04 19:41:54 +0100 |
---|---|---|
committer | drew cimino <dcimino@gitlab.com> | 2019-04-12 16:53:21 +0100 |
commit | 34243489af3e52ca87d6f1bc578bd9ba4e9d565e (patch) | |
tree | 478c5ded9c01a98b8677503d2e41f5daa3ae7e5a /spec/views | |
parent | de44f3e176a1891238f5c79ef5203ab06cbe6927 (diff) | |
download | gitlab-ce-34243489af3e52ca87d6f1bc578bd9ba4e9d565e.tar.gz |
Don't render artifact download links on the project tags page for builds with expired artifacts
Diffstat (limited to 'spec/views')
-rw-r--r-- | spec/views/projects/tags/index.html.haml_spec.rb | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/spec/views/projects/tags/index.html.haml_spec.rb b/spec/views/projects/tags/index.html.haml_spec.rb index cb97d17988c..32e90e222d9 100644 --- a/spec/views/projects/tags/index.html.haml_spec.rb +++ b/spec/views/projects/tags/index.html.haml_spec.rb @@ -1,20 +1,56 @@ require 'spec_helper' describe 'projects/tags/index' do - let(:project) { create(:project, :repository) } + let(:project) { create(:project, :repository) } + let(:tags) { TagsFinder.new(project.repository, {}).execute } + let(:git_tag) { project.repository.tags.last } + let(:release) { create(:release, project: project, sha: git_tag.target_commit.sha) } + let(:pipeline) { create(:ci_pipeline, :success, project: project, ref: git_tag.name, sha: release.sha) } + + let(:artifacts_download_header_regex) { %r(<li class="dropdown-bold-header">Download artifacts<\/li>) } + let(:artifacts_download_link_selector) { 'a[href="' + latest_succeeded_project_artifacts_path(project, "#{pipeline.ref}/download", job: 'test') + '"]' } before do assign(:project, project) assign(:repository, project.repository) - assign(:tags, []) + assign(:releases, project.releases) + assign(:tags, Kaminari.paginate_array(tags).page(0)) + assign(:tags_pipelines, { git_tag.name => pipeline }) allow(view).to receive(:current_ref).and_return('master') - allow(view).to receive(:can?).and_return(false) + allow(view).to receive(:current_user).and_return(project.namespace.owner) end it 'defaults sort dropdown toggle to last updated' do render - expect(rendered).to have_button('Last updated') end + + context 'when the most recent build for a tag has artifacts' do + let!(:build) { create(:ci_build, :success, :artifacts, pipeline: pipeline) } + + it 'renders the Artifacts section in the download list' do + render + expect(rendered).to match(artifacts_download_header_regex) + end + + it 'renders artifact download links' do + render + expect(rendered).to have_selector(artifacts_download_link_selector) + end + end + + context 'when the most recent build for a tag has expired artifacts' do + let!(:build) { create(:ci_build, :success, :expired, :artifacts, pipeline: pipeline) } + + it 'does not render the Artifacts section in the download list' do + render + expect(rendered).not_to match(artifacts_download_header_regex) + end + + it 'renders artifact download links' do + render + expect(rendered).not_to have_selector(artifacts_download_link_selector) + end + end end |