gitlab-org--gitlab-foss/spec/controllers/projects/repositories_controller_spec.rb

44 lines
1.3 KiB
Ruby
Raw Normal View History

2015-03-31 07:37:21 -04:00
require "spec_helper"
describe Projects::RepositoriesController do
let(:project) { create(:project, :repository) }
2015-03-31 07:37:21 -04:00
describe "GET archive" do
context 'as a guest' do
it 'responds with redirect in correct format' do
get :archive, namespace_id: project.namespace, project_id: project, format: "zip", ref: 'master'
2015-03-31 07:37:21 -04:00
expect(response.header["Content-Type"]).to start_with('text/html')
expect(response).to be_redirect
end
2015-03-31 07:37:21 -04:00
end
context 'as a user' do
let(:user) { create(:user) }
2015-03-31 07:37:21 -04:00
before do
project.team << [user, :developer]
sign_in(user)
2015-03-31 07:37:21 -04:00
end
it "uses Gitlab::Workhorse" do
get :archive, namespace_id: project.namespace, project_id: project, ref: "master", format: "zip"
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")
end
it "renders Not Found" do
get :archive, namespace_id: project.namespace, project_id: project, ref: "master", format: "zip"
2015-03-31 07:37:21 -04:00
expect(response).to have_gitlab_http_status(404)
end
2015-03-31 07:37:21 -04:00
end
end
end
end