From 6bf436f19f3f1e13aebff6f017d86ec5a19f0707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Mon, 29 Sep 2025 12:13:51 +0200 Subject: [PATCH] fixtures :all --- .rubocop.yml | 3 +-- .../attachments_controller_patch_test.rb | 2 -- .../custom_workflows_controller_test.rb | 1 - .../groups_controller_patch_test.rb | 1 - .../issue_relations_controller_patch_test.rb | 3 --- .../issues_controller_patch_test.rb | 3 --- .../members_controller_patch_test.rb | 1 - .../projects_controller_patch_test.rb | 2 -- .../timelog_controller_patch_test.rb | 3 --- .../functional/users_controller_patch_test.rb | 1 - .../versions_controller_patch_test.rb | 1 - test/functional/wiki_controller_patch_test.rb | 3 --- test/test_case.rb | 20 +++++++------------ test/unit/attachment_patch_test.rb | 1 - test/unit/custom_workflow_mailer_test.rb | 1 - test/unit/custom_workflow_test.rb | 1 - test/unit/group_patch_test.rb | 1 - test/unit/issue_patch_test.rb | 1 - test/unit/issue_relation_patch_test.rb | 1 - test/unit/member_patch_test.rb | 1 - test/unit/project_patch_test.rb | 1 - test/unit/time_entry_patch_test.rb | 1 - test/unit/user_patch_test.rb | 1 - test/unit/version_patch_test.rb | 1 - test/unit/wiki_content_patch_test.rb | 1 - test/unit/wiki_page_patch_test.rb | 1 - test/unit_test.rb | 17 ++++++++-------- 27 files changed, 17 insertions(+), 57 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index df9fb02..9b33bef 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -24,8 +24,7 @@ AllCops: Exclude: - '**/vendor/**/*' -# Enable extensions -require: +plugins: - rubocop-performance - rubocop-rails diff --git a/test/functional/attachments_controller_patch_test.rb b/test/functional/attachments_controller_patch_test.rb index 3923c97..8da9256 100644 --- a/test/functional/attachments_controller_patch_test.rb +++ b/test/functional/attachments_controller_patch_test.rb @@ -21,8 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # Attachment controller patch test class AttachmentsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase - fixtures :attachments, :enabled_modules, :custom_workflows, :custom_workflows_projects, - :roles, :members, :member_roles def setup super diff --git a/test/functional/custom_workflows_controller_test.rb b/test/functional/custom_workflows_controller_test.rb index 908df79..29e32f8 100644 --- a/test/functional/custom_workflows_controller_test.rb +++ b/test/functional/custom_workflows_controller_test.rb @@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # Custom workflows controller test class CustomWorkflowsControllerTest < RedmineCustomWorkflows::Test::TestCase - fixtures :custom_workflows def setup super diff --git a/test/functional/groups_controller_patch_test.rb b/test/functional/groups_controller_patch_test.rb index 58ffb9f..4e1d9b5 100644 --- a/test/functional/groups_controller_patch_test.rb +++ b/test/functional/groups_controller_patch_test.rb @@ -22,7 +22,6 @@ require File.expand_path('../../test_helper', __FILE__) # Group controller patch test class GroupControllerPatchTest < RedmineCustomWorkflows::Test::TestCase include Rails.application.routes.url_helpers - fixtures :custom_workflows, :custom_workflows_projects def setup super diff --git a/test/functional/issue_relations_controller_patch_test.rb b/test/functional/issue_relations_controller_patch_test.rb index 2bd7a97..78c0149 100644 --- a/test/functional/issue_relations_controller_patch_test.rb +++ b/test/functional/issue_relations_controller_patch_test.rb @@ -21,9 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # Issue relation controller patch test class IssueRelationsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase - fixtures :user_preferences, :issues, :versions, :trackers, :projects_trackers, :issue_statuses, - :enabled_modules, :enumerations, :issue_categories, :custom_workflows, :custom_workflows_projects, - :issue_relations, :roles, :members, :member_roles, :attachments def setup super diff --git a/test/functional/issues_controller_patch_test.rb b/test/functional/issues_controller_patch_test.rb index 7886ca0..1f6e5c7 100644 --- a/test/functional/issues_controller_patch_test.rb +++ b/test/functional/issues_controller_patch_test.rb @@ -21,9 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # Issue controller patch test class IssuesControllerPatchTest < RedmineCustomWorkflows::Test::TestCase - fixtures :user_preferences, :issues, :versions, :trackers, :projects_trackers, :issue_statuses, - :enabled_modules, :enumerations, :issue_categories, :custom_workflows, :custom_workflows_projects, :roles, - :members, :member_roles def setup super diff --git a/test/functional/members_controller_patch_test.rb b/test/functional/members_controller_patch_test.rb index 3108d77..6bfc94b 100644 --- a/test/functional/members_controller_patch_test.rb +++ b/test/functional/members_controller_patch_test.rb @@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # Users controller patch test class MembersControllerPatchTest < RedmineCustomWorkflows::Test::TestCase - fixtures :user_preferences, :roles, :members, :member_roles, :custom_workflows, :custom_workflows_projects def setup super diff --git a/test/functional/projects_controller_patch_test.rb b/test/functional/projects_controller_patch_test.rb index 8ec8fad..adc5733 100644 --- a/test/functional/projects_controller_patch_test.rb +++ b/test/functional/projects_controller_patch_test.rb @@ -21,8 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # Project controller patch test class ProjectsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase - fixtures :user_preferences, :issues, :versions, :trackers, :projects_trackers, :enabled_modules, - :enumerations, :custom_workflows, :custom_workflows_projects, :roles, :members, :member_roles def setup super diff --git a/test/functional/timelog_controller_patch_test.rb b/test/functional/timelog_controller_patch_test.rb index 851f502..8e6df31 100644 --- a/test/functional/timelog_controller_patch_test.rb +++ b/test/functional/timelog_controller_patch_test.rb @@ -21,9 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # Time controller patch test class TimelogControllerPatchTest < RedmineCustomWorkflows::Test::TestCase - fixtures :user_preferences, :issues, :versions, :trackers, :projects_trackers, :issue_statuses, - :enabled_modules, :enumerations, :issue_categories, :custom_workflows, :custom_workflows_projects, - :time_entries, :roles, :members, :member_roles def setup super diff --git a/test/functional/users_controller_patch_test.rb b/test/functional/users_controller_patch_test.rb index 54bbcf5..1d8d4a1 100644 --- a/test/functional/users_controller_patch_test.rb +++ b/test/functional/users_controller_patch_test.rb @@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # Users controller patch test class UsersControllerPatchTest < RedmineCustomWorkflows::Test::TestCase - fixtures :custom_workflows, :custom_workflows_projects def setup super diff --git a/test/functional/versions_controller_patch_test.rb b/test/functional/versions_controller_patch_test.rb index 6b9dc3b..43fbbf3 100644 --- a/test/functional/versions_controller_patch_test.rb +++ b/test/functional/versions_controller_patch_test.rb @@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # Version controller patch test class VersionsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase - fixtures :versions, :custom_workflows, :custom_workflows_projects, :roles, :members, :member_roles def setup super diff --git a/test/functional/wiki_controller_patch_test.rb b/test/functional/wiki_controller_patch_test.rb index 48c89f7..2288c95 100644 --- a/test/functional/wiki_controller_patch_test.rb +++ b/test/functional/wiki_controller_patch_test.rb @@ -21,9 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # Wiki controller patch test class WikiControllerPatchTest < RedmineCustomWorkflows::Test::TestCase - fixtures :user_preferences, :issues, :versions, :trackers, :projects_trackers, :enabled_modules, - :enumerations, :wikis, :wiki_pages, :wiki_contents, :custom_workflows, :custom_workflows_projects, - :roles, :members, :member_roles def setup super diff --git a/test/test_case.rb b/test/test_case.rb index e5229d0..69eeb9b 100644 --- a/test/test_case.rb +++ b/test/test_case.rb @@ -21,22 +21,16 @@ module RedmineCustomWorkflows module Test # Test case base class class TestCase < ActionDispatch::IntegrationTest - fixtures :users, :email_addresses, :projects - # Allow us to override the fixtures method to implement fixtures for our plugin. - # Ultimately it allows for better integration without blowing redmine fixtures up, - # and allowing us to suppliment redmine fixtures if we need to. - def self.fixtures(*table_names) + def initialize(name) + super(name) + # Load all plugin's fixtures dir = File.join(File.dirname(__FILE__), 'fixtures') - redmine_table_names = [] - table_names.each do |x| - if File.exist?(File.join(dir, "#{x}.yml")) - ActiveRecord::FixtureSet.create_fixtures(dir, x) - else - redmine_table_names << x - end + ext = '.yml' + Dir.glob("#{dir}/**/*#{ext}").each do |file| + fixture = File.basename(file, ext) + ActiveRecord::FixtureSet.create_fixtures dir, fixture end - super(redmine_table_names) if redmine_table_names.any? end def setup diff --git a/test/unit/attachment_patch_test.rb b/test/unit/attachment_patch_test.rb index 2ff4c7f..a1f694b 100644 --- a/test/unit/attachment_patch_test.rb +++ b/test/unit/attachment_patch_test.rb @@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # Attachment patch test class class AttachmentPatchTest < RedmineCustomWorkflows::Test::UnitTest - fixtures :attachments def setup @attachment1 = Attachment.find 1 diff --git a/test/unit/custom_workflow_mailer_test.rb b/test/unit/custom_workflow_mailer_test.rb index 9df57be..0a3db3d 100644 --- a/test/unit/custom_workflow_mailer_test.rb +++ b/test/unit/custom_workflow_mailer_test.rb @@ -22,7 +22,6 @@ require File.expand_path('../../test_helper', __FILE__) # Custom mailer test class class CustomWorkflowMailerTest < RedmineCustomWorkflows::Test::UnitTest include Redmine::I18n - fixtures :users, :email_addresses def setup @user2 = User.find 2 diff --git a/test/unit/custom_workflow_test.rb b/test/unit/custom_workflow_test.rb index c49c353..f8f0250 100644 --- a/test/unit/custom_workflow_test.rb +++ b/test/unit/custom_workflow_test.rb @@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # Custom workflow test class class CustomWorkflowTest < RedmineCustomWorkflows::Test::UnitTest - fixtures :projects, :custom_workflows, :custom_workflows_projects def setup @cw1 = CustomWorkflow.find 1 diff --git a/test/unit/group_patch_test.rb b/test/unit/group_patch_test.rb index e1b934c..9b29cf6 100644 --- a/test/unit/group_patch_test.rb +++ b/test/unit/group_patch_test.rb @@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # Group patch test class class GroupPatchTest < RedmineCustomWorkflows::Test::UnitTest - fixtures :users def setup @group10 = Group.find 10 diff --git a/test/unit/issue_patch_test.rb b/test/unit/issue_patch_test.rb index 7d43c9e..d1ca580 100644 --- a/test/unit/issue_patch_test.rb +++ b/test/unit/issue_patch_test.rb @@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # Issue patch test class class IssuePatchTest < RedmineCustomWorkflows::Test::UnitTest - fixtures :issues def setup @issue1 = Issue.find 1 diff --git a/test/unit/issue_relation_patch_test.rb b/test/unit/issue_relation_patch_test.rb index 6bcc55f..8193ecf 100644 --- a/test/unit/issue_relation_patch_test.rb +++ b/test/unit/issue_relation_patch_test.rb @@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # Issue relation patch test class class IssueRelationPatchTest < RedmineCustomWorkflows::Test::UnitTest - fixtures :issue_relations def setup @issue_relation1 = IssueRelation.find 1 diff --git a/test/unit/member_patch_test.rb b/test/unit/member_patch_test.rb index 0930565..4f38940 100644 --- a/test/unit/member_patch_test.rb +++ b/test/unit/member_patch_test.rb @@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # Member patch test class class MemberPatchTest < RedmineCustomWorkflows::Test::UnitTest - fixtures :members def setup @member1 = Member.find 1 diff --git a/test/unit/project_patch_test.rb b/test/unit/project_patch_test.rb index bd4e43f..269084c 100644 --- a/test/unit/project_patch_test.rb +++ b/test/unit/project_patch_test.rb @@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # Project patch test class class ProjectPatchTest < RedmineCustomWorkflows::Test::UnitTest - fixtures :projects def setup @project1 = Project.find 1 diff --git a/test/unit/time_entry_patch_test.rb b/test/unit/time_entry_patch_test.rb index b729966..b7663b8 100644 --- a/test/unit/time_entry_patch_test.rb +++ b/test/unit/time_entry_patch_test.rb @@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # Time entry patch test class class TimeEntryPatchTest < RedmineCustomWorkflows::Test::UnitTest - fixtures :time_entries def setup @time_entry1 = TimeEntry.find 1 diff --git a/test/unit/user_patch_test.rb b/test/unit/user_patch_test.rb index 8c041f3..7960d7f 100644 --- a/test/unit/user_patch_test.rb +++ b/test/unit/user_patch_test.rb @@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # User patch test class class UserPatchTest < RedmineCustomWorkflows::Test::UnitTest - fixtures :users def setup @user1 = User.find 1 diff --git a/test/unit/version_patch_test.rb b/test/unit/version_patch_test.rb index d0aab1a..77f1361 100644 --- a/test/unit/version_patch_test.rb +++ b/test/unit/version_patch_test.rb @@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # Version patch test class class VersionPatchTest < RedmineCustomWorkflows::Test::UnitTest - fixtures :versions def setup @version1 = Version.find 1 diff --git a/test/unit/wiki_content_patch_test.rb b/test/unit/wiki_content_patch_test.rb index 996efe7..ced182d 100644 --- a/test/unit/wiki_content_patch_test.rb +++ b/test/unit/wiki_content_patch_test.rb @@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # Wiki content patch test class class WikiContentPatchTest < RedmineCustomWorkflows::Test::UnitTest - fixtures :wiki_contents def setup @wiki_content1 = WikiContent.find 1 diff --git a/test/unit/wiki_page_patch_test.rb b/test/unit/wiki_page_patch_test.rb index 6da6094..f3f8c08 100644 --- a/test/unit/wiki_page_patch_test.rb +++ b/test/unit/wiki_page_patch_test.rb @@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__) # Wiki page test class class WikiPagePatchTest < RedmineCustomWorkflows::Test::UnitTest - fixtures :wiki_pages def setup @wiki_page1 = WikiPage.find 1 diff --git a/test/unit_test.rb b/test/unit_test.rb index edf8dea..e443f89 100644 --- a/test/unit_test.rb +++ b/test/unit_test.rb @@ -21,15 +21,16 @@ module RedmineCustomWorkflows module Test # Unit test base class class UnitTest < ActiveSupport::TestCase - # Allow us to override the fixtures method to implement fixtures for our plugin. - # Ultimately it allows for better integration without blowing redmine fixtures up, - # and allowing us to suppliment redmine fixtures if we need to. - def self.fixtures(*table_names) - dir = File.join(File.dirname(__FILE__), '/fixtures') - table_names.each do |x| - ActiveRecord::FixtureSet.create_fixtures(dir, x) if File.exist?("#{dir}/#{x}.yml") + + def initialize(name) + super(name) + # Load all plugin's fixtures + dir = File.join(File.dirname(__FILE__), 'fixtures') + ext = '.yml' + Dir.glob("#{dir}/**/*#{ext}").each do |file| + fixture = File.basename(file, ext) + ActiveRecord::FixtureSet.create_fixtures dir, fixture end - super(table_names) end protected