Project

General

Profile

Defect #44751 ยป 0001-restore-settings-of-Redmine-Configuration-with-when-the-block-raises.patch

Nishida Yuya, 2026-11-14 13:41

View differences:

lib/redmine/configuration.rb
92 92
        was = settings.keys.index_with { |v| @config[v] }
93 93
        @config.merge! settings
94 94
        yield if block_given?
95
        @config.merge! was
95
      ensure
96
        @config.merge! was if was
96 97
      end
97 98

  
98 99
      private
test/unit/lib/redmine/configuration_test.rb
53 53
    assert_equal 'foo', @conf['somesetting']
54 54
  end
55 55

  
56
  def test_with_should_restore_settings_if_the_block_raises
57
    load_conf('default.yml', 'test')
58
    assert_raise RuntimeError do
59
      @conf.with 'somesetting' => 'bar' do
60
        raise 'error'
61
      end
62
    end
63
    assert_equal 'foo', @conf['somesetting']
64
  end
65

  
56 66
  private
57 67

  
58 68
  def load_conf(file, env)
    (1-1/1)