diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-04-19 17:00:32 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-04-19 17:00:32 +0300 |
commit | 82fb02fff6942f42a8e6c9c8846f914ff714c686 (patch) | |
tree | 5b88d724e2e364d4cd86b7c8d38d9cf5e4dd41bb /spec/controllers | |
parent | 4eb02d5991e962e259347c11e736f72c9dc17e56 (diff) | |
parent | 276d4eb80cade01f1d035d849a90009d02ae926d (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/controllers')
-rw-r--r-- | spec/controllers/projects/repositories_controller_spec.rb | 24 |
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") |