2019-07-31 22:56:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Groups::UploadsController do
|
2018-11-08 19:23:39 +05:30
|
|
|
include WorkhorseHelpers
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:model) { create(:group, :public) }
|
|
|
|
let(:params) do
|
|
|
|
{ group_id: model }
|
|
|
|
end
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
let(:other_model) { create(:group, :public) }
|
|
|
|
let(:other_params) do
|
|
|
|
{ group_id: other_model }
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it_behaves_like 'handle uploads' do
|
|
|
|
let(:uploader_class) { NamespaceFileUploader }
|
|
|
|
end
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
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-11-08 19:23:39 +05:30
|
|
|
def post_authorize(verified: true)
|
|
|
|
request.headers.merge!(workhorse_internal_api_request_header) if verified
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
post :authorize, params: { group_id: model.full_path }, format: :json
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|