From 2b8eb7273efee84180b322a0aac33e1f4ee30d2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Fri, 25 May 2018 18:44:15 +0200 Subject: Ensure ApplicationSetting#performance_bar_allowed_group_id is properly set when retrieved from cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- app/services/application_settings/update_service.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app/services/application_settings') diff --git a/app/services/application_settings/update_service.rb b/app/services/application_settings/update_service.rb index d6d3a661dab..e70445cfb67 100644 --- a/app/services/application_settings/update_service.rb +++ b/app/services/application_settings/update_service.rb @@ -3,6 +3,10 @@ module ApplicationSettings def execute update_terms(@params.delete(:terms)) + if params.key?(:performance_bar_allowed_group_path) + params[:performance_bar_allowed_group_id] = performance_bar_allowed_group_id + end + @application_setting.update(@params) end @@ -18,5 +22,13 @@ module ApplicationSettings ApplicationSetting::Term.create(terms: terms) @application_setting.reset_memoized_terms end + + def performance_bar_allowed_group_id + performance_bar_enabled = !params.key?(:performance_bar_enabled) || params.delete(:performance_bar_enabled) + group_full_path = params.delete(:performance_bar_allowed_group_path) + return nil unless Gitlab::Utils.to_boolean(performance_bar_enabled) + + Group.find_by_full_path(group_full_path)&.id if group_full_path.present? + end end end -- cgit v1.2.3