b44a2c801a
Updates specs to use new rails5 format. The old format: `get :show, { some: params }, { some: headers }` The new format: `get :show, params: { some: params }, headers: { some: headers }`
40 lines
1.1 KiB
Ruby
40 lines
1.1 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe Projects::UploadsController do
|
|
include WorkhorseHelpers
|
|
|
|
let(:model) { create(:project, :public) }
|
|
let(:params) do
|
|
{ namespace_id: model.namespace.to_param, project_id: model }
|
|
end
|
|
|
|
it_behaves_like 'handle uploads'
|
|
|
|
context 'when the URL the old style, without /-/system' do
|
|
it 'responds with a redirect to the login page' do
|
|
get :show, params: { namespace_id: 'project', project_id: 'avatar', filename: 'foo.png', secret: 'bar' }
|
|
|
|
expect(response).to redirect_to(new_user_session_path)
|
|
end
|
|
end
|
|
|
|
context "when exception occurs" do
|
|
before do
|
|
allow(FileUploader).to receive(:workhorse_authorize).and_raise(SocketError.new)
|
|
sign_in(create(:user))
|
|
end
|
|
|
|
it "responds with status internal_server_error" do
|
|
post_authorize
|
|
|
|
expect(response).to have_gitlab_http_status(500)
|
|
expect(response.body).to eq('Error uploading file')
|
|
end
|
|
end
|
|
|
|
def post_authorize(verified: true)
|
|
request.headers.merge!(workhorse_internal_api_request_header) if verified
|
|
|
|
post :authorize, params: { namespace_id: model.namespace, project_id: model.path }, format: :json
|
|
end
|
|
end
|