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
path: root/spec
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-04-19 17:00:32 +0300
committerFilipa Lacerda <filipa@gitlab.com>2018-04-20 12:30:43 +0300
commitf65ce40cdeba862aa101360ee1db03adc59d9823 (patch)
tree0e0610d0a82a588481ec95cfcbf8a188189b3c4d /spec
parentdef7611f3e970bb56a341716c3bd7af6fd499b02 (diff)
Merge branch '45507-fix-repository-archive-url' into 'master'
Fix specifying a non-default ref when requesting an archive using the legacy URL Closes #45507 See merge request gitlab-org/gitlab-ce!18468
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/projects/repositories_controller_spec.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/controllers/projects/repositories_controller_spec.rb b/spec/controllers/projects/repositories_controller_spec.rb
index c3b71458e38..a102a3a3c8c 100644
--- a/spec/controllers/projects/repositories_controller_spec.rb
+++ b/spec/controllers/projects/repositories_controller_spec.rb
@@ -40,6 +40,30 @@ describe Projects::RepositoriesController do
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:")
end
+ it 'handles legacy queries with the ref specified as ref in params' do
+ get :archive, namespace_id: project.namespace, project_id: project, ref: 'feature', format: 'zip'
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(assigns(:ref)).to eq('feature')
+ expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:")
+ end
+
+ it 'handles legacy queries with the ref specified as id in params' do
+ get :archive, namespace_id: project.namespace, project_id: project, id: 'feature', format: 'zip'
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(assigns(:ref)).to eq('feature')
+ expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:")
+ end
+
+ it 'prioritizes the id param over the ref param when both are specified' do
+ get :archive, namespace_id: project.namespace, project_id: project, id: 'feature', ref: 'feature_conflict', format: 'zip'
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(assigns(:ref)).to eq('feature')
+ expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:")
+ end
+
context "when the service raises an error" do
before do
allow(Gitlab::Workhorse).to receive(:send_git_archive).and_raise("Archive failed")