mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
ability to set custom maximum space
This commit is contained in:
parent
0c8bba8114
commit
3035175c4f
3 changed files with 24 additions and 1 deletions
9
migrations/074_add_custom_max_space.rb
Normal file
9
migrations/074_add_custom_max_space.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
Sequel.migration do
|
||||
up {
|
||||
DB.add_column :sites, :custom_max_space, :bigint, default: 0
|
||||
}
|
||||
|
||||
down {
|
||||
DB.drop_column :sites, :custom_max_space
|
||||
}
|
||||
end
|
|
@ -960,7 +960,11 @@ class Site < Sequel::Model
|
|||
end
|
||||
|
||||
def maximum_space
|
||||
PLAN_FEATURES[(parent? ? self : parent).plan_type.to_sym][:space]
|
||||
plan_space = PLAN_FEATURES[(parent? ? self : parent).plan_type.to_sym][:space]
|
||||
|
||||
return custom_max_space if custom_max_space > plan_space
|
||||
|
||||
plan_space
|
||||
end
|
||||
|
||||
def space_percentage_used
|
||||
|
|
|
@ -5,6 +5,16 @@ def app
|
|||
end
|
||||
|
||||
describe Site do
|
||||
describe 'custom_max_space' do
|
||||
it 'should use the custom max space if it is more' do
|
||||
site = Fabricate :site
|
||||
site.maximum_space.must_equal Site::PLAN_FEATURES[:free][:space]
|
||||
site.custom_max_space = 10**9
|
||||
site.save_changes
|
||||
site.maximum_space.must_equal 10**9
|
||||
end
|
||||
end
|
||||
|
||||
describe 'can_email' do
|
||||
it 'should fail if send_emails is false' do
|
||||
site = Fabricate :site
|
||||
|
|
Loading…
Add table
Reference in a new issue