From d004f14867b4f9e459a87dcae015945e089fe473 Mon Sep 17 00:00:00 2001
From: Takashi Kato <tohosaku@users.osdn.me>
Date: Thu, 10 Aug 2023 23:07:10 +0000
Subject: [PATCH 4/4] Add dependency test

---
 doc/RUNNING_TESTS                    | 6 ++++++
 test/unit/lib/redmine/plugin_test.rb | 8 ++++++++
 2 files changed, 14 insertions(+)

diff --git a/doc/RUNNING_TESTS b/doc/RUNNING_TESTS
index fa4737e11..03655aced 100644
--- a/doc/RUNNING_TESTS
+++ b/doc/RUNNING_TESTS
@@ -21,6 +21,12 @@ variable:
 Before running tests, you need to configure both development
 and test databases.
 
+To test if a gem plugin is loaded, do the following
+
+`export BUNDLE_GEMFILE=./test/fixtures/gem_plugins/Gemfile`
+`bundle install`
+`bin/rails test test/unit/lib/redmine/plugin_test.rb`
+
 Creating test repositories
 ==========================
 
diff --git a/test/unit/lib/redmine/plugin_test.rb b/test/unit/lib/redmine/plugin_test.rb
index ad24a3f33..1461e4152 100644
--- a/test/unit/lib/redmine/plugin_test.rb
+++ b/test/unit/lib/redmine/plugin_test.rb
@@ -80,6 +80,14 @@ class Redmine::PluginTest < ActiveSupport::TestCase
     assert_equal '0.0.1', plugin.version
   end
 
+  def test_gemified_plugin_depended_by_other_plugin
+    skip unless gemfile_for_test?
+    path = Redmine::PluginLoader.find_path(plugin_id: "quux_plugin", plugin_dir: nil)
+    path.run_initializer
+    plugin = @klass.find('quux_plugin')
+    assert_equal :quux_plugin, plugin.id
+  end
+
   def test_invalid_gemified_plugin
     skip unless gemfile_for_test?
     path = Redmine::PluginLoader.find_path(plugin_id: nil, plugin_dir: File.join(@klass.directory, 'qux_plugin'))
-- 
2.39.2

