debian-mirror-gitlab/spec/controllers/projects/repositories_controller_spec.rb

44 lines
1.3 KiB
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
require "spec_helper"
describe Projects::RepositoriesController do
let(:project) { create(:project) }
describe "GET archive" do
2016-06-02 11:05:42 +05:30
context 'as a guest' do
it 'responds with redirect in correct format' do
get :archive, namespace_id: project.namespace.path, project_id: project.path, format: "zip"
2015-04-26 12:48:37 +05:30
2016-11-03 12:29:30 +05:30
expect(response.header["Content-Type"]).to start_with('text/html')
2016-06-02 11:05:42 +05:30
expect(response).to be_redirect
end
2015-04-26 12:48:37 +05:30
end
2016-06-02 11:05:42 +05:30
context 'as a user' do
let(:user) { create(:user) }
2015-04-26 12:48:37 +05:30
before do
2016-06-02 11:05:42 +05:30
project.team << [user, :developer]
sign_in(user)
2015-04-26 12:48:37 +05:30
end
it "uses Gitlab::Workhorse" do
2015-04-26 12:48:37 +05:30
get :archive, namespace_id: project.namespace.path, project_id: project.path, ref: "master", format: "zip"
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:")
2016-06-02 11:05:42 +05:30
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.path, project_id: project.path, ref: "master", format: "zip"
2015-04-26 12:48:37 +05:30
2016-08-24 12:49:21 +05:30
expect(response).to have_http_status(404)
2016-06-02 11:05:42 +05:30
end
2015-04-26 12:48:37 +05:30
end
end
end
end