Follow up #2345: Default value for Setting 'es_attachment_max_size_in_mb' is not in sync and to high.
This commit is contained in:
parent
6be530bb1c
commit
1e512f6cd0
3 changed files with 38 additions and 1 deletions
|
@ -0,0 +1,13 @@
|
||||||
|
class Issue2345EsAttachmentMaxSizeInMbSettingLowerDefault < ActiveRecord::Migration[5.1]
|
||||||
|
def change
|
||||||
|
|
||||||
|
# return if it's a new setup to avoid running the migration
|
||||||
|
return if !Setting.find_by(name: 'system_init_done')
|
||||||
|
|
||||||
|
# don't change non default/custom value
|
||||||
|
return if Setting.get('es_attachment_max_size_in_mb') != 50
|
||||||
|
|
||||||
|
# set new default value
|
||||||
|
Setting.set('es_attachment_max_size_in_mb', 10)
|
||||||
|
end
|
||||||
|
end
|
|
@ -2761,7 +2761,7 @@ Setting.create_if_not_exists(
|
||||||
name: 'es_attachment_max_size_in_mb',
|
name: 'es_attachment_max_size_in_mb',
|
||||||
area: 'SearchIndex::Elasticsearch',
|
area: 'SearchIndex::Elasticsearch',
|
||||||
description: 'Define max. attachment size for Elasticsearch.',
|
description: 'Define max. attachment size for Elasticsearch.',
|
||||||
state: 50,
|
state: 10,
|
||||||
preferences: { online_service_disable: true },
|
preferences: { online_service_disable: true },
|
||||||
frontend: false
|
frontend: false
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Issue2345EsAttachmentMaxSizeInMbSettingLowerDefault, type: :db_migration do
|
||||||
|
|
||||||
|
context 'Issue2345EsAttachmentMaxSizeInMbSettingLowerDefault migration' do
|
||||||
|
|
||||||
|
it 'decreases the default value' do
|
||||||
|
allow(Setting).to receive(:get).with('es_attachment_max_size_in_mb').and_return(50)
|
||||||
|
migrate
|
||||||
|
# reset/remove mocks
|
||||||
|
RSpec::Mocks.space.proxy_for(Setting).reset
|
||||||
|
expect(Setting.get('es_attachment_max_size_in_mb')).not_to be(50)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'preserves custom Setting value' do
|
||||||
|
allow(Setting).to receive(:get).with('es_attachment_max_size_in_mb').and_return(5)
|
||||||
|
expect { migrate }.not_to change { Setting.get('es_attachment_max_size_in_mb') }
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'performs no action for new systems', system_init_done: false do
|
||||||
|
expect { migrate }.not_to change { Setting.get('es_attachment_max_size_in_mb') }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue