Project

General

Profile

Actions

Defect #40856

open

random failing integration test for plugin routes in 5.1.3

Added by Evgeni Golov 5 months ago. Updated 3 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

Hi,

I think this is related to #38707 and #39864. I have a plugin that carries routes and when I run rails test with that plugin installed, the tests randomly fail in 5.1-stable (and 5.1.3).

Here is a sort-of-minimal reproducer:

user@host % git clone -b 5.1-stable https://github.com/redmine/redmine
Cloning into 'redmine'...
remote: Enumerating objects: 199100, done.
remote: Counting objects: 100% (4955/4955), done.
remote: Compressing objects: 100% (1562/1562), done.
remote: Total 199100 (delta 3587), reused 4404 (delta 3328), pack-reused 194145
Receiving objects: 100% (199100/199100), 87.42 MiB | 28.39 MiB/s, done.
Resolving deltas: 100% (157526/157526), done.

user@host % cd redmine/plugins 

user@host % git clone -b redmine-5 https://github.com/theforeman/redmine_lightbox2
Cloning into 'redmine_lightbox2'...
remote: Enumerating objects: 850, done.
remote: Counting objects: 100% (36/36), done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 850 (delta 11), reused 28 (delta 10), pack-reused 814
Receiving objects: 100% (850/850), 226.67 KiB | 3.15 MiB/s, done.
Resolving deltas: 100% (369/369), done.

user@host % cd ..
user@host % printf 'test:\n  adapter: sqlite3\n  database: db/redmine.sqlite3' > config/database.yml
user@host % bundle install   
user@host % SCMS=git DATABASE_ADAPTER=sqlite3 RAILS_ENV=test bundle exec rake ci:setup redmine:plugins:migrate

user@host % SCMS=git DATABASE_ADAPTER=sqlite3 RAILS_ENV=test bundle exec rails test --seed 14026

The following failure is expected (the plugin changes the layout of attachments):

Failure:
IssuesControllerTest#test_show_with_thumbnails_enabled_should_display_thumbnails [test/functional/issues_controller_test.rb:2781]:
Expected at least 1 element matching "a[href=\"/attachments/16\"]", found 0.
Expected 0 to be >= 1.

The following (and similar others from the same file) are not expected:

WikiControllerTest#test_show_page_without_edit_link:
RuntimeError: Neutered Exception ActionView::Template::Error: No route matches {:action=>"download_inline", :controller=>"attachments", :filename=>"ecookbook-gantt.pdf", :id=>#<Attachment id: 23, container_id: 1, container_type: "WikiPage", filename: "ecookbook-gantt.pdf", disk_filename: "190511141819_ecookbook-gantt.pdf", filesize: 31620, content_type: "application/pdf", digest: "da9c52e79d9eee7d47b9ee5db477985c542ea683e9f23ed32d...", downloads: 0, author_id: 2, created_on: "2019-05-11 05:18:19.000000000 +0000", description: "Gantt chart as of May 11", disk_directory: "2019/05">, :project_id=>"1"}
    plugins/redmine_lightbox2/app/views/attachments/_links.html.erb:32
    plugins/redmine_lightbox2/app/views/attachments/_links.html.erb:12
    app/helpers/attachments_helper.rb:52:in `link_to_attachments'
    app/views/wiki/show.html.erb:68
    lib/redmine/sudo_mode.rb:61:in `sudo_mode'
    test/functional/wiki_controller_test.rb:1158:in `test_show_page_without_edit_link'

Neither is this:

Failure:
WikiIntegrationTest#test_updating_a_renamed_page [test/integration/wiki_test.rb:39]:
Expected response to be a <2XX: success>, but was a <500: Internal Server Error>

The same tests do not fail on 5.0.6 and I could not see them fail on trunk (r22882) either.

The following patch makes the tests work reliably, but I think it's a crude hack:

commit 0d26803f78ff3e3ef87b7df34740090aa912c6d6
Author: Evgeni Golov <evgeni@golov.de>
Date:   Tue Jun 18 12:54:53 2024 +0200

    reset Redmine::Plugin.directory to Rails.root/plugins

    otherwise plugin routes are not properly loaded and tests fail

diff --git a/test/integration/routing/plugins_test.rb b/test/integration/routing/plugins_test.rb
index ddbf415a1..beb8597e7 100644
--- a/test/integration/routing/plugins_test.rb
+++ b/test/integration/routing/plugins_test.rb
@@ -65,6 +65,7 @@ class RoutingPluginsTest < Redmine::RoutingTest

     Redmine::Plugin.clear
     Redmine::PluginLoader.directory = @original_plugin_dir
+    Redmine::Plugin.directory = Rails.root.join('plugins')
     Redmine::PluginLoader.load
     RedmineApp::Application.instance.routes_reloader.reload!
   end

Setting Plugin.directory to @original_plugin_dir does not seem to fix it, which I find strange.

Actions

Also available in: Atom PDF