From 26264625cbc2692bc113c1e701cb15eecbd010d2 Mon Sep 17 00:00:00 2001 From: Ruben Davila Date: Thu, 7 Sep 2017 09:10:39 -0500 Subject: Small refactor after last code review. --- lib/gitlab/themes.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/gitlab/themes.rb b/lib/gitlab/themes.rb index 37054d98102..d43eff5ba4a 100644 --- a/lib/gitlab/themes.rb +++ b/lib/gitlab/themes.rb @@ -73,13 +73,11 @@ module Gitlab private def default_id - id = Gitlab.config.gitlab.default_theme.to_i + @default_id ||= begin + id = Gitlab.config.gitlab.default_theme.to_i + theme_ids = THEMES.map(&:id) - # Prevent an invalid configuration setting from causing an infinite loop - if id < THEMES.first.id || id > THEMES.last.id - APPLICATION_DEFAULT - else - id + theme_ids.include?(id) ? id : APPLICATION_DEFAULT end end end -- cgit v1.2.1