Commit 0f1d6402 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Find the LFS-objects for a fork within a the fork network

parent 7582bc8b
...@@ -94,10 +94,9 @@ module LfsRequest ...@@ -94,10 +94,9 @@ module LfsRequest
@storage_project ||= begin @storage_project ||= begin
result = project result = project
loop do # TODO: Make this go to the fork_network root immeadiatly
break unless result.forked? # dependant on the discussion in: https://gitlab.com/gitlab-org/gitlab-ce/issues/39769
result = result.forked_from_project result = result.fork_source while result.forked?
end
result result
end end
......
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 ...@@ -38,6 +38,10 @@ module StubConfiguration
allow(Gitlab.config.backup).to receive_messages(to_settings(messages)) allow(Gitlab.config.backup).to receive_messages(to_settings(messages))
end end
def stub_lfs_setting(messages)
allow(Gitlab.config.lfs).to receive_messages(to_settings(messages))
end
def stub_storage_settings(messages) def stub_storage_settings(messages)
# Default storage is always required # Default storage is always required
messages['default'] ||= Gitlab.config.repositories.storages.default messages['default'] ||= Gitlab.config.repositories.storages.default
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment