def self.check_cache
settings_updated_on = Setting.maximum(:updated_on)
if settings_updated_on && @cached_cleared_on <= settings_updated_on
- @cached_settings.clear
- @cached_cleared_on = Time.now
- logger.info "Settings cache cleared." if logger
+ clear_cache
end
end
+
+ # Clears the settings cache
+ def self.clear_cache
+ @cached_settings.clear
+ @cached_cleared_on = Time.now
+ logger.info "Settings cache cleared." if logger
+ end
private
# Returns the Setting instance for the setting named name
assert_equal ['issue_added', 'issue_updated', 'news_added'], Setting.notified_events
assert_equal ['issue_added', 'issue_updated', 'news_added'], Setting.find_by_name('notified_events').value
end
+
+ def test_setting_should_be_reloaded_after_clear_cache
+ Setting.app_title = "My title"
+ assert_equal "My title", Setting.app_title
+
+ s = Setting.find_by_name("app_title")
+ s.value = 'New title'
+ s.save!
+ assert_equal "My title", Setting.app_title
+
+ Setting.clear_cache
+ assert_equal "New title", Setting.app_title
+ end
end