Skip to content
Snippets Groups Projects
Commit 9c41c7ac authored by Gabriel Mazetto's avatar Gabriel Mazetto
Browse files

Make `#hashed_storage?` require feature argument

parent 6a4534b6
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -1614,7 +1614,10 @@ class Project < ActiveRecord::Base
[nil, 0].include?(self.storage_version)
end
 
def hashed_storage?(feature=:repository)
# Check if Hashed Storage is enabled for the project with at least informed feature rolled out
#
# @param [Symbol] feature that needs to be rolled out for the project (:repository, :attachments)
def hashed_storage?(feature)
raise ArgumentError, "Invalid feature" unless HASHED_STORAGE_FEATURES.include?(feature)
 
self.storage_version && self.storage_version >= HASHED_STORAGE_FEATURES[feature]
Loading
Loading
@@ -1653,7 +1656,7 @@ class Project < ActiveRecord::Base
end
 
def migrate_to_hashed_storage!
return if hashed_storage?
return if hashed_storage?(:repository)
 
update!(repository_read_only: true)
 
Loading
Loading
@@ -1678,7 +1681,7 @@ class Project < ActiveRecord::Base
 
def storage
@storage ||=
if hashed_storage?
if hashed_storage?(:repository)
Storage::HashedProject.new(self)
else
Storage::LegacyProject.new(self)
Loading
Loading
Loading
Loading
@@ -10,7 +10,7 @@ module Projects
end
 
def execute
return if project.hashed_storage?
return if project.hashed_storage?(:repository)
 
@old_disk_path = project.disk_path
has_wiki = project.wiki.repository_exists?
Loading
Loading
Loading
Loading
@@ -2494,7 +2494,7 @@ describe Project do
 
describe '#hashed_storage?' do
it 'returns false' do
expect(project.hashed_storage?).to be_falsey
expect(project.hashed_storage?(:repository)).to be_falsey
end
end
 
Loading
Loading
@@ -2630,22 +2630,14 @@ describe Project do
end
 
describe '#hashed_storage?' do
context 'without specifying feature' do
it 'returns true' do
expect(project.hashed_storage?).to be_truthy
end
it 'returns true if rolled out' do
expect(project.hashed_storage?(:attachments)).to be_truthy
end
 
context 'specifying feature' do
it 'returns true if rolled out' do
expect(project.hashed_storage?(:attachments)).to be_truthy
end
it 'returns false when not rolled out yet' do
project.storage_version = 1
it 'returns false when not rolled out yet' do
project.storage_version = 1
 
expect(project.hashed_storage?(:attachments)).to be_falsey
end
expect(project.hashed_storage?(:attachments)).to be_falsey
end
end
 
Loading
Loading
Loading
Loading
@@ -23,7 +23,7 @@ describe Projects::HashedStorageMigrationService do
it 'updates project to be hashed and not read-only' do
service.execute
 
expect(project.hashed_storage?).to be_truthy
expect(project.hashed_storage?(:repository)).to be_truthy
expect(project.repository_read_only).to be_falsey
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment