Find the LFS-objects for a fork within a the fork network
This commit is contained in:
parent
7582bc8b4e
commit
0f1d6402b9
3 changed files with 57 additions and 4 deletions
|
@ -94,10 +94,9 @@ module LfsRequest
|
|||
@storage_project ||= begin
|
||||
result = project
|
||||
|
||||
loop do
|
||||
break unless result.forked?
|
||||
result = result.forked_from_project
|
||||
end
|
||||
# TODO: Make this go to the fork_network root immeadiatly
|
||||
# dependant on the discussion in: https://gitlab.com/gitlab-org/gitlab-ce/issues/39769
|
||||
result = result.fork_source while result.forked?
|
||||
|
||||
result
|
||||
end
|
||||
|
|
50
spec/controllers/concerns/lfs_request_spec.rb
Normal file
50
spec/controllers/concerns/lfs_request_spec.rb
Normal file
|
@ -0,0 +1,50 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe LfsRequest do
|
||||
include ProjectForksHelper
|
||||
|
||||
controller(Projects::GitHttpClientController) do
|
||||
# `described_class` is not available in this context
|
||||
include LfsRequest # rubocop:disable RSpec/DescribedClass
|
||||
|
||||
def show
|
||||
storage_project
|
||||
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
def project
|
||||
@project ||= Project.find(params[:id])
|
||||
end
|
||||
|
||||
def download_request?
|
||||
true
|
||||
end
|
||||
|
||||
def ci?
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
let(:project) { create(:project, :public) }
|
||||
|
||||
before do
|
||||
stub_lfs_setting(enabled: true)
|
||||
end
|
||||
|
||||
describe '#storage_project' do
|
||||
it 'assigns the project as storage project' do
|
||||
get :show, id: project.id
|
||||
|
||||
expect(assigns(:storage_project)).to eq(project)
|
||||
end
|
||||
|
||||
it 'assigns the source of a forked project' do
|
||||
forked_project = fork_project(project)
|
||||
|
||||
get :show, id: forked_project.id
|
||||
|
||||
expect(assigns(:storage_project)).to eq(project)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -38,6 +38,10 @@ module StubConfiguration
|
|||
allow(Gitlab.config.backup).to receive_messages(to_settings(messages))
|
||||
end
|
||||
|
||||
def stub_lfs_setting(messages)
|
||||
allow(Gitlab.config.lfs).to receive_messages(to_settings(messages))
|
||||
end
|
||||
|
||||
def stub_storage_settings(messages)
|
||||
# Default storage is always required
|
||||
messages['default'] ||= Gitlab.config.repositories.storages.default
|
||||
|
|
Loading…
Reference in a new issue