Defect #44751 ยป 0001-restore-settings-of-Redmine-Configuration-with-when-the-block-raises.patch
| lib/redmine/configuration.rb | ||
|---|---|---|
|
was = settings.keys.index_with { |v| @config[v] }
|
||
|
@config.merge! settings
|
||
|
yield if block_given?
|
||
|
@config.merge! was
|
||
|
ensure
|
||
|
@config.merge! was if was
|
||
|
end
|
||
|
private
|
||
| test/unit/lib/redmine/configuration_test.rb | ||
|---|---|---|
|
assert_equal 'foo', @conf['somesetting']
|
||
|
end
|
||
|
def test_with_should_restore_settings_if_the_block_raises
|
||
|
load_conf('default.yml', 'test')
|
||
|
assert_raise RuntimeError do
|
||
|
@conf.with 'somesetting' => 'bar' do
|
||
|
raise 'error'
|
||
|
end
|
||
|
end
|
||
|
assert_equal 'foo', @conf['somesetting']
|
||
|
end
|
||
|
private
|
||
|
def load_conf(file, env)
|
||