##// END OF EJS Templates
Adds a method to temporarily override configuration settings....
Jean-Philippe Lang -
r4829:e1ad561cf652
parent child
Show More
@@ -66,6 +66,16 module Redmine
66 66 @config[name]
67 67 end
68 68
69 # Yields a block with the specified hash configuration settings
70 def with(settings)
71 settings.stringify_keys!
72 load unless @config
73 was = settings.keys.inject({}) {|h,v| h[v] = @config[v]; h}
74 @config.merge! settings
75 yield if block_given?
76 @config.merge! was
77 end
78
69 79 private
70 80
71 81 def load_from_yaml(filename, env)
@@ -41,6 +41,15 class Redmine::ConfigurationTest < ActiveSupport::TestCase
41 41 assert_equal 'bar', @conf['somesetting']
42 42 end
43 43
44 def test_with
45 load_conf('default.yml', 'test')
46 assert_equal 'foo', @conf['somesetting']
47 @conf.with 'somesetting' => 'bar' do
48 assert_equal 'bar', @conf['somesetting']
49 end
50 assert_equal 'foo', @conf['somesetting']
51 end
52
44 53 private
45 54
46 55 def load_conf(file, env)
General Comments 0
You need to be logged in to leave comments. Login now