Project

General

Profile

Patch #31110 » 0002-Change-to-raise-an-exception-v2.patch

Mizuki ISHIKAWA, 2019-04-09 03:28

View differences:

lib/redmine/plugin.rb
98 98
      # Set a default directory if it was not provided during registration
99 99
      p.directory(File.join(self.directory, id.to_s)) if p.directory.nil?
100 100

  
101
      unless File.directory?(p.directory)
102
        raise PluginNotFound, "Plugin not found. The directory for plugin #{p.id} should be #{p.directory}."
103
      end
104

  
101 105
      # Adds plugin locales if any
102 106
      # YAML translation files should be found under <plugin>/config/locales/
103 107
      Rails.application.config.i18n.load_path += Dir.glob(File.join(p.directory, 'config', 'locales', '*.yml'))
test/unit/lib/redmine/plugin_test.rb
57 57
    assert_equal '0.0.1', plugin.version
58 58
  end
59 59

  
60
  def test_register_should_raise_error_if_plugin_directory_does_not_exist
61
    e = assert_raises Redmine::PluginNotFound do
62
      @klass.register(:bar_plugin) {}
63
    end
64

  
65
    assert_equal "Plugin not found. The directory for plugin bar_plugin should be #{Rails.root.join('test/fixtures/plugins/bar_plugin')}.", e.message
66
  end
67

  
60 68
  def test_installed
61 69
    @klass.register(:foo_plugin) {}
62 70
    assert_equal true, @klass.installed?(:foo_plugin)
(3-3/3)