revolutionhealth-config_loader 2.0.40655071 → 2.0.118251957
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/config_loader.rb +2 -2
- data/test/test_config_reload.rb +14 -6
- data/test/test_helper.rb +4 -1
- data/test/test_service_config.rb +1 -2
- metadata +1 -1
data/lib/config_loader.rb
CHANGED
@@ -49,8 +49,8 @@ class ConfigurationLoader
|
|
49
49
|
@caching = (cache_option == :force_cache)
|
50
50
|
@base_path = base_path
|
51
51
|
# defer caching until rails has finished initializing and thus all gems are loaded
|
52
|
-
if cache_option == :defer_cache && Object.const_defined?(:Rails)
|
53
|
-
Rails
|
52
|
+
if cache_option == :defer_cache && Object.const_defined?(:Rails) && Rails.respond_to?(:configuration)
|
53
|
+
Rails.configuration.after_initialize do
|
54
54
|
self.instance_eval { @caching = true }
|
55
55
|
end
|
56
56
|
end
|
data/test/test_config_reload.rb
CHANGED
@@ -27,6 +27,7 @@ end
|
|
27
27
|
class TestConfigReload < Test::Unit::TestCase
|
28
28
|
|
29
29
|
def test_config_reload
|
30
|
+
ConfigLoader.instance_eval { @caching = true } # enable caching
|
30
31
|
loaded = ConfigLoader.load_file('test_reload.yml')
|
31
32
|
assert_not_nil loaded
|
32
33
|
assert ConfigLoader.loader_called
|
@@ -94,6 +95,8 @@ class TestConfigReload < Test::Unit::TestCase
|
|
94
95
|
File.open( test_reload_file, 'w' ) do |out|
|
95
96
|
YAML.dump(loaded, out )
|
96
97
|
end
|
98
|
+
ensure
|
99
|
+
ConfigLoader.instance_eval { @caching = false } # disable caching
|
97
100
|
end
|
98
101
|
|
99
102
|
def test_check_only
|
@@ -103,13 +106,18 @@ class TestConfigReload < Test::Unit::TestCase
|
|
103
106
|
end
|
104
107
|
|
105
108
|
def test_use_alternate_base_path
|
109
|
+
orig_rails_root = RAILS_ROOT
|
106
110
|
Object.send(:remove_const, "RAILS_ROOT")
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
111
|
+
begin
|
112
|
+
assert_raise(RuntimeError) {
|
113
|
+
ConfigurationLoader.new(false).send(:app_root)
|
114
|
+
}
|
115
|
+
top_dir = File.join(File.dirname(__FILE__), '..')
|
116
|
+
conf = ConfigurationLoader.new(false, top_dir)
|
117
|
+
assert conf.send(:app_root).first == File.expand_path(top_dir)
|
118
|
+
ensure
|
119
|
+
Object.const_set(:RAILS_ROOT, orig_rails_root)
|
120
|
+
end
|
113
121
|
end
|
114
122
|
|
115
123
|
end
|
data/test/test_helper.rb
CHANGED
@@ -2,6 +2,9 @@ require 'test/unit'
|
|
2
2
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'config_loader')
|
3
3
|
|
4
4
|
unless defined?(RAILS_ENV)
|
5
|
-
RAILS_ROOT = File.dirname(__FILE__)
|
6
5
|
RAILS_ENV = 'test'
|
6
|
+
end
|
7
|
+
|
8
|
+
unless defined?(RAILS_ROOT)
|
9
|
+
RAILS_ROOT = File.dirname(__FILE__)
|
7
10
|
end
|
data/test/test_service_config.rb
CHANGED