Commit dac8cf9a authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '201886-move-blob-lfs-enabled-lookup' into 'master'

Move the blob LFS enabled lookup to the repository

See merge request gitlab-org/gitlab!29204
parents bacead2d fdb32ee4
......@@ -129,7 +129,7 @@ class Blob < SimpleDelegator
def external_storage_error?
if external_storage == :lfs
!project&.lfs_enabled?
!repository.lfs_enabled?
else
false
end
......
......@@ -1120,6 +1120,17 @@ class Repository
end
end
# TODO: pass this in directly to `Blob` rather than delegating it to here
#
# https://gitlab.com/gitlab-org/gitlab/-/issues/201886
def lfs_enabled?
if container.is_a?(Project)
container.lfs_enabled?
else
false # LFS is not supported for snippet or group repositories
end
end
private
# TODO Genericize finder, later split this on finders by Ref or Oid
......
......@@ -219,6 +219,29 @@ describe Repository do
end
end
describe '#lfs_enabled? (design repositories)' do
let(:project) { create(:project, :design_repo, lfs_enabled: lfs_enabled) }
let(:repository) { project.design_repository }
before do
stub_lfs_setting(enabled: true)
end
subject { repository.lfs_enabled? }
context 'project has LFS disabled' do
let(:lfs_enabled) { false }
it { is_expected.to be_falsy }
end
context 'project has LFS enabled' do
let(:lfs_enabled) { true }
it { is_expected.to be_truthy }
end
end
describe '#upstream_branch_name' do
let(:pull_mirror_branch_prefix) { 'upstream/' }
let(:branch_name) { 'upstream/master' }
......
This diff is collapsed.
......@@ -2874,4 +2874,64 @@ describe Repository do
expect(repository.submodule_links).to be_a(Gitlab::SubmoduleLinks)
end
end
describe '#lfs_enabled?' do
let_it_be(:project) { create(:project, :repository, lfs_enabled: true) }
subject { repository.lfs_enabled? }
context 'for a project repository' do
let(:repository) { project.repository }
it 'returns true when LFS is enabled' do
stub_lfs_setting(enabled: true)
is_expected.to be_truthy
end
it 'returns false when LFS is disabled' do
stub_lfs_setting(enabled: false)
is_expected.to be_falsy
end
end
context 'for a project wiki repository' do
let(:repository) { project.wiki.repository }
it 'returns true when LFS is enabled' do
stub_lfs_setting(enabled: true)
is_expected.to be_truthy
end
it 'returns false when LFS is disabled' do
stub_lfs_setting(enabled: false)
is_expected.to be_falsy
end
end
context 'for a project snippet repository' do
let(:snippet) { create(:project_snippet, project: project) }
let(:repository) { snippet.repository }
it 'returns false when LFS is enabled' do
stub_lfs_setting(enabled: true)
is_expected.to be_falsy
end
end
context 'for a personal snippet repository' do
let(:snippet) { create(:personal_snippet) }
let(:repository) { snippet.repository }
it 'returns false when LFS is enabled' do
stub_lfs_setting(enabled: true)
is_expected.to be_falsy
end
end
end
end
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