diff options
Diffstat (limited to 'spec/controllers/projects')
-rw-r--r-- | spec/controllers/projects/artifacts_controller_spec.rb | 12 | ||||
-rw-r--r-- | spec/controllers/projects/releases_controller_spec.rb | 46 |
2 files changed, 49 insertions, 9 deletions
diff --git a/spec/controllers/projects/artifacts_controller_spec.rb b/spec/controllers/projects/artifacts_controller_spec.rb index 7aaaa363faa..c59983d5138 100644 --- a/spec/controllers/projects/artifacts_controller_spec.rb +++ b/spec/controllers/projects/artifacts_controller_spec.rb @@ -138,14 +138,14 @@ describe Projects::ArtifactsController do let(:filename) { job.artifacts_file.filename } it 'sends the artifacts file' do - # Notice the filename= is omitted from the disposition; this is because - # Rails 5 will append this header in send_file expect(controller).to receive(:send_file) .with( job.artifacts_file.file.path, - hash_including(disposition: %Q(attachment; filename*=UTF-8''#{filename}))).and_call_original + hash_including(disposition: 'attachment', filename: filename)).and_call_original download_artifact + + expect(response.headers['Content-Disposition']).to eq(%Q(attachment; filename="#{filename}"; filename*=UTF-8''#{filename})) end end @@ -170,13 +170,13 @@ describe Projects::ArtifactsController do end it 'sends the codequality report' do - # Notice the filename= is omitted from the disposition; this is because - # Rails 5 will append this header in send_file expect(controller).to receive(:send_file) .with(job.job_artifacts_codequality.file.path, - hash_including(disposition: %Q(attachment; filename*=UTF-8''#{filename}))).and_call_original + hash_including(disposition: 'attachment', filename: filename)).and_call_original download_artifact(file_type: file_type) + + expect(response.headers['Content-Disposition']).to eq(%Q(attachment; filename="#{filename}"; filename*=UTF-8''#{filename})) end end diff --git a/spec/controllers/projects/releases_controller_spec.rb b/spec/controllers/projects/releases_controller_spec.rb index 6abb58e1aa6..a03fabad2de 100644 --- a/spec/controllers/projects/releases_controller_spec.rb +++ b/spec/controllers/projects/releases_controller_spec.rb @@ -127,13 +127,13 @@ describe Projects::ReleasesController do sign_in(user) end - let!(:release) { create(:release, project: project) } + let(:release) { create(:release, project: project) } let(:tag) { CGI.escape(release.tag) } it_behaves_like 'successful request' context 'when tag name contains slash' do - let!(:release) { create(:release, project: project, tag: 'awesome/v1.0') } + let(:release) { create(:release, project: project, tag: 'awesome/v1.0') } let(:tag) { CGI.escape(release.tag) } it_behaves_like 'successful request' @@ -145,7 +145,6 @@ describe Projects::ReleasesController do end context 'when release does not exist' do - let!(:release) { } let(:tag) { 'non-existent-tag' } it_behaves_like 'not found' @@ -158,6 +157,47 @@ describe Projects::ReleasesController do end end + describe 'GET #show' do + subject do + get :show, params: { namespace_id: project.namespace, project_id: project, tag: tag } + end + + before do + sign_in(user) + end + + let(:release) { create(:release, project: project) } + let(:tag) { CGI.escape(release.tag) } + + it_behaves_like 'successful request' + + context 'when tag name contains slash' do + let(:release) { create(:release, project: project, tag: 'awesome/v1.0') } + let(:tag) { CGI.escape(release.tag) } + + it_behaves_like 'successful request' + + it 'is accesible at a URL encoded path' do + expect(project_release_path(project, release)) + .to eq("/#{project.namespace.path}/#{project.name}/-/releases/awesome%252Fv1.0") + end + end + + context 'when feature flag `release_show_page` is disabled' do + before do + stub_feature_flags(release_show_page: false) + end + + it_behaves_like 'not found' + end + + context 'when release does not exist' do + let(:tag) { 'non-existent-tag' } + + it_behaves_like 'not found' + end + end + describe 'GET #evidence' do let_it_be(:tag_name) { "v1.1.0-evidence" } let!(:release) { create(:release, :with_evidence, project: project, tag: tag_name) } |