Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/concerns/metrics_dashboard_spec.rb2
-rw-r--r--spec/controllers/concerns/send_file_upload_spec.rb24
-rw-r--r--spec/controllers/projects/artifacts_controller_spec.rb12
-rw-r--r--spec/controllers/projects/releases_controller_spec.rb46
-rw-r--r--spec/controllers/uploads_controller_spec.rb2
5 files changed, 53 insertions, 33 deletions
diff --git a/spec/controllers/concerns/metrics_dashboard_spec.rb b/spec/controllers/concerns/metrics_dashboard_spec.rb
index 6ab02057412..466021d6ecd 100644
--- a/spec/controllers/concerns/metrics_dashboard_spec.rb
+++ b/spec/controllers/concerns/metrics_dashboard_spec.rb
@@ -23,7 +23,7 @@ describe MetricsDashboard do
routes.draw { get "metrics_dashboard" => "anonymous#metrics_dashboard" }
response = get :metrics_dashboard, format: :json
- JSON.parse(response.parsed_body)
+ response.parsed_body
end
context 'when no parameters are provided' do
diff --git a/spec/controllers/concerns/send_file_upload_spec.rb b/spec/controllers/concerns/send_file_upload_spec.rb
index 4110be721ad..3cfb7b5a488 100644
--- a/spec/controllers/concerns/send_file_upload_spec.rb
+++ b/spec/controllers/concerns/send_file_upload_spec.rb
@@ -59,11 +59,9 @@ describe SendFileUpload do
let(:params) { { disposition: 'inline', attachment: filename } }
it 'sends a file with inline disposition' do
- # Notice the filename= is omitted from the disposition; this is because
- # Rails 5 will append this header in send_file
expected_params = {
filename: 'test.png',
- disposition: "inline; filename*=UTF-8''test.png"
+ disposition: 'inline'
}
expect(controller).to receive(:send_file).with(uploader.path, expected_params)
@@ -76,34 +74,16 @@ describe SendFileUpload do
let(:params) { { attachment: filename } }
it 'sends a file with content-type of text/plain' do
- # Notice the filename= is omitted from the disposition; this is because
- # Rails 5 will append this header in send_file
expected_params = {
content_type: 'text/plain',
filename: 'test.js',
- disposition: "attachment; filename*=UTF-8''test.js"
+ disposition: 'attachment'
}
expect(controller).to receive(:send_file).with(uploader.path, expected_params)
subject
end
- context 'with non-ASCII encoded filename' do
- let(:filename) { 'ใƒ†ใ‚นใƒˆ.txt' }
-
- # Notice the filename= is omitted from the disposition; this is because
- # Rails 5 will append this header in send_file
- it 'sends content-disposition for non-ASCII encoded filenames' do
- expected_params = {
- filename: filename,
- disposition: "attachment; filename*=UTF-8''%E3%83%86%E3%82%B9%E3%83%88.txt"
- }
- expect(controller).to receive(:send_file).with(uploader.path, expected_params)
-
- subject
- end
- end
-
context 'with a proxied file in object storage' do
before do
stub_uploads_object_storage(uploader: uploader_class)
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) }
diff --git a/spec/controllers/uploads_controller_spec.rb b/spec/controllers/uploads_controller_spec.rb
index 69e2c085659..f42d0560e80 100644
--- a/spec/controllers/uploads_controller_spec.rb
+++ b/spec/controllers/uploads_controller_spec.rb
@@ -649,7 +649,7 @@ describe UploadsController do
get :show, params: { model: 'appearance', mounted_as: 'favicon', id: appearance.id, filename: 'dk.png' }
expect(response).to have_gitlab_http_status(:ok)
- expect(response.header['Content-Disposition']).to end_with 'filename="dk.png"'
+ expect(response.header['Content-Disposition']).to include('filename="dk.png"')
end
end