app/models/setting.rb in fat_free_crm-0.11.3 vs app/models/setting.rb in fat_free_crm-0.11.4

- old
+ new

@@ -110,33 +110,26 @@ table_exists? rescue false end # Loads settings from YAML files - def load_settings_from_yaml - @@yaml_settings = {}.with_indifferent_access - - setting_files = [ - FatFreeCRM.root.join("config", "settings.default.yml"), - Rails.root.join("config", "settings.yml") - ] - - # Load default settings, then override with custom settings - setting_files.each do |file| - if File.exist?(file) - begin - settings = YAML.load_file(file) - # Merge settings into current settings hash (recursively) - @@yaml_settings.deep_merge!(settings) - rescue Exception => ex - puts "Settings couldn't be loaded from #{file}: #{ex.message}" - end - end + def load_settings_from_yaml(file) + begin + settings = YAML.load_file(file) + # Merge settings into current settings hash (recursively) + @@yaml_settings.deep_merge!(settings) + rescue Exception => ex + puts "Settings couldn't be loaded from #{file}: #{ex.message}" end yaml_settings end end end -# Preload YAML settings as soon as class is loaded. -Setting.load_settings_from_yaml +# Load default settings, then override with custom settings, if present. +setting_files = [FatFreeCRM.root.join("config", "settings.default.yml")] +# Don't override default settings in test environment +setting_files << Rails.root.join("config", "settings.yml") unless Rails.env == 'test' +setting_files.each do |settings_file| + Setting.load_settings_from_yaml(settings_file) if File.exist?(settings_file) +end