2019-04-15 06:17:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-06 06:36:11 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 23:08:05 -04:00
|
|
|
RSpec.describe Groups::UploadsController do
|
2018-06-12 11:54:37 -04:00
|
|
|
include WorkhorseHelpers
|
|
|
|
|
2017-12-06 06:36:11 -05:00
|
|
|
let(:model) { create(:group, :public) }
|
|
|
|
let(:params) do
|
|
|
|
{ group_id: model }
|
|
|
|
end
|
|
|
|
|
2019-07-11 00:48:50 -04:00
|
|
|
let(:other_model) { create(:group, :public) }
|
|
|
|
let(:other_params) do
|
|
|
|
{ group_id: other_model }
|
|
|
|
end
|
|
|
|
|
2018-01-29 12:57:34 -05:00
|
|
|
it_behaves_like 'handle uploads' do
|
|
|
|
let(:uploader_class) { NamespaceFileUploader }
|
|
|
|
end
|
2018-06-12 11:54:37 -04:00
|
|
|
|
2020-01-13 04:08:03 -05:00
|
|
|
context 'with a moved group' do
|
|
|
|
let!(:upload) { create(:upload, :issuable_upload, :with_file, model: model) }
|
|
|
|
let(:group) { model }
|
|
|
|
let(:old_path) { group.to_param + 'old' }
|
|
|
|
let!(:redirect_route) { model.redirect_routes.create(path: old_path) }
|
|
|
|
let(:upload_path) { File.basename(upload.path) }
|
|
|
|
|
|
|
|
it 'redirects to a file with the proper extension' do
|
|
|
|
get :show, params: { group_id: old_path, filename: upload_path, secret: upload.secret }
|
|
|
|
|
|
|
|
expect(response.location).to eq(show_group_uploads_url(group, upload.secret, upload_path))
|
|
|
|
expect(response.location).to end_with(upload.path)
|
|
|
|
expect(response).to have_gitlab_http_status(:redirect)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-06-12 11:54:37 -04:00
|
|
|
def post_authorize(verified: true)
|
|
|
|
request.headers.merge!(workhorse_internal_api_request_header) if verified
|
|
|
|
|
2018-12-17 17:52:17 -05:00
|
|
|
post :authorize, params: { group_id: model.full_path }, format: :json
|
2018-06-12 11:54:37 -04:00
|
|
|
end
|
2017-12-06 06:36:11 -05:00
|
|
|
end
|