diff options
Diffstat (limited to 'spec/controllers/projects/artifacts_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/artifacts_controller_spec.rb | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/spec/controllers/projects/artifacts_controller_spec.rb b/spec/controllers/projects/artifacts_controller_spec.rb index 00efd7d7b56..3d12926c07a 100644 --- a/spec/controllers/projects/artifacts_controller_spec.rb +++ b/spec/controllers/projects/artifacts_controller_spec.rb @@ -26,14 +26,34 @@ RSpec.describe Projects::ArtifactsController do subject { get :index, params: { namespace_id: project.namespace, project_id: project } } context 'when feature flag is on' do + render_views + before do stub_feature_flags(artifacts_management_page: true) end - it 'renders the page' do + it 'renders the page with data for the artifacts app' do subject expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template('projects/artifacts/index') + + app = Nokogiri::HTML.parse(response.body).at_css('div#js-artifact-management') + + expect(app.attributes['data-project-path'].value).to eq(project.full_path) + expect(app.attributes['data-can-destroy-artifacts'].value).to eq('true') + end + + describe 'when user does not have permission to delete artifacts' do + let(:user) { create(:user) } + + it 'passes false to the artifacts app' do + subject + + app = Nokogiri::HTML.parse(response.body).at_css('div#js-artifact-management') + + expect(app.attributes['data-can-destroy-artifacts'].value).to eq('false') + end end end @@ -423,6 +443,16 @@ RSpec.describe Projects::ArtifactsController do end end + context 'when artifacts archive is missing' do + let!(:job) { create(:ci_build, :success, pipeline: pipeline) } + + it 'returns 404' do + subject + + expect(response).to have_gitlab_http_status(:not_found) + end + end + context 'fetching an artifact of different type' do before do job.job_artifacts.each(&:destroy) |