Skip to content

Commit 3858424

Browse files
aespinoza-quoinpnabutovsky
authored andcommitted
Merged in r2-2807-fix-default-maximum_attachments_per_record (pull request #6747)
R2-2807 Fix default maximum_attachments_per_record
2 parents c6b1bd1 + 852f983 commit 3858424

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

app/models/system_settings.rb

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# SystemSetting should be invoked using the singleton SystemSettings#current method.
99
# Any update to the data will only take effect after the system is rebooted
1010
# and the singleton is reloaded.
11+
# rubocop:disable Metrics/ClassLength
1112
class SystemSettings < ApplicationRecord
1213
include LocalizableJsonProperty
1314
include ConfigurationRecord
@@ -144,6 +145,10 @@ def maximum_users_fields_present?
144145
maximum_users.is_a?(Integer) && maximum_users_warning.is_a?(Integer)
145146
end
146147

148+
def maximum_attachments_per_record
149+
super || Attachment::DEFAULT_MAX_ATTACHMENTS
150+
end
151+
147152
class << self
148153
def current(rebuild = false)
149154
return @current unless @current.nil? || rebuild
@@ -174,3 +179,4 @@ def primary_age_ranges
174179
end
175180
end
176181
end
182+
# rubocop:enable Metrics/ClassLength

app/views/api/v2/system_settings/index.json.jbuilder

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ json.data do
1515
json.reporting_location_config current_user.role.reporting_location_config
1616
json.approvals_labels FieldI18nService.to_localized_values(@system_setting.approvals_labels_i18n)
1717
json.export_require_password ZipService.require_password?
18+
json.system_options @system_setting.system_options
19+
.merge('maximum_attachments_per_record' =>
20+
@system_setting.maximum_attachments_per_record)
1821
if code_of_conduct
1922
json.code_of_conduct do
2023
json.partial! 'api/v2/codes_of_conduct/code_of_conduct', code_of_conduct:

spec/models/system_settings_spec.rb

+6
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,11 @@
7373
expect(@system_settings).to be_valid
7474
end
7575
end
76+
77+
context '#maximum_attachments_per_record' do
78+
it 'when is not defined return default value' do
79+
expect(@system_settings.maximum_attachments_per_record).to eq(Attachment::DEFAULT_MAX_ATTACHMENTS)
80+
end
81+
end
7682
end
7783
end

spec/requests/api/v2/system_settings_controller_spec.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@
6868
case_plan: 'Case Plan',
6969
closure: 'Closure'
7070
},
71-
maximum_users: 55,
72-
maximum_attachments_per_record: 23
71+
maximum_users: 55
7372
)
7473
end
7574

@@ -88,7 +87,7 @@
8887
expect(json['data']['system_options']['maximum_users']).to eq(@system_settings.maximum_users)
8988
expect(
9089
json['data']['system_options']['maximum_attachments_per_record']
91-
).to eq(@system_settings.maximum_attachments_per_record)
90+
).to eq(@system_settings.maximum_attachments_per_record)
9291
end
9392

9493
it 'lists system_settings and all agencies and all modules when the param *extended* is true on the request' do

0 commit comments

Comments
 (0)