2015-03-31 07:37:21 -04:00
|
|
|
require "spec_helper"
|
|
|
|
|
|
|
|
describe Projects::RepositoriesController do
|
2017-01-25 16:44:33 -05:00
|
|
|
let(:project) { create(:project, :repository) }
|
2015-03-31 07:37:21 -04:00
|
|
|
|
|
|
|
describe "GET archive" do
|
2016-02-15 21:17:20 -05:00
|
|
|
context 'as a guest' do
|
|
|
|
it 'responds with redirect in correct format' do
|
2017-08-03 12:44:48 -04:00
|
|
|
get :archive, namespace_id: project.namespace, project_id: project, format: "zip", ref: 'master'
|
2015-03-31 07:37:21 -04:00
|
|
|
|
2016-09-27 22:52:41 -04:00
|
|
|
expect(response.header["Content-Type"]).to start_with('text/html')
|
2016-02-15 21:17:20 -05:00
|
|
|
expect(response).to be_redirect
|
|
|
|
end
|
2015-03-31 07:37:21 -04:00
|
|
|
end
|
|
|
|
|
2016-02-15 21:17:20 -05:00
|
|
|
context 'as a user' do
|
|
|
|
let(:user) { create(:user) }
|
2015-03-31 07:37:21 -04:00
|
|
|
|
|
|
|
before do
|
2016-02-15 21:17:20 -05:00
|
|
|
project.team << [user, :developer]
|
|
|
|
sign_in(user)
|
2015-03-31 07:37:21 -04:00
|
|
|
end
|
|
|
|
|
2016-06-06 07:16:30 -04:00
|
|
|
it "uses Gitlab::Workhorse" do
|
2017-02-23 18:55:01 -05:00
|
|
|
get :archive, namespace_id: project.namespace, project_id: project, ref: "master", format: "zip"
|
2016-06-06 07:16:30 -04:00
|
|
|
|
|
|
|
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:")
|
2016-02-15 21:17:20 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when the service raises an error" do
|
|
|
|
before do
|
|
|
|
allow(Gitlab::Workhorse).to receive(:send_git_archive).and_raise("Archive failed")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "renders Not Found" do
|
2017-02-23 18:55:01 -05:00
|
|
|
get :archive, namespace_id: project.namespace, project_id: project, ref: "master", format: "zip"
|
2015-03-31 07:37:21 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(404)
|
2016-02-15 21:17:20 -05:00
|
|
|
end
|
2015-03-31 07:37:21 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|