Merge branch 'devel'

This commit is contained in:
Karel Pičman 2025-10-03 09:45:21 +02:00
commit 7bd3d30773
43 changed files with 95 additions and 150 deletions

View File

@ -82,7 +82,7 @@ jobs:
sudo apt-get install subversion
- name: Clone Redmine
# Get the latest stable Redmine
run: svn export http://svn.redmine.org/redmine/branches/6.0-stable/ /opt/redmine
run: svn export http://svn.redmine.org/redmine/branches/6.1-stable/ /opt/redmine
- name: Checkout code
uses: actions/checkout@v3
- name: Link the plugin

View File

@ -15,19 +15,18 @@
# You should have received a copy of the GNU General Public License along with Redmine Custom Workflows plugin. If not,
# see <https://www.gnu.org/licenses/>.
plugins:
rubocop-rails
AllCops:
TargetRubyVersion: 3.2
TargetRailsVersion: 7.1
NewCops: enable
SuggestExtensions: false
Exclude:
- '**/vendor/**/*'
# Enable extensions
require:
- rubocop-performance
- rubocop-rails
NewCops: enable
# Rules for CustomWorkflows
Metrics/BlockLength:

View File

@ -1,8 +1,17 @@
# Changelog for Custom Workflows
3.0.2 *2025-10-03*
------------------
Chinese localisation
Redmine 6.1 compatibility
* New: #362 - Chinese (Simplified) locale
3.0.1 *2025-07-07*
------------------
SQL Server compatibility
Change of the license from GNU GPL v2 to v3
* New: #360 - GNU GPL v2 -> v3
* Bug: #359 - Can't install plugin with redmine 6.0.5 in docker container

View File

@ -1,4 +1,4 @@
# Custom Workflows plug-in 3.0.1
# Custom Workflows plug-in 3.0.2
[![GitHub CI](https://github.com/anteo/redmine_custom_workflows/actions/workflows/rubyonrails.yml/badge.svg?branch=master)](https://github.com/anteo/redmine_custom_workflows/actions/workflows/rubyonrails.yml)
[![Support Ukraine Badge](https://bit.ly/support-ukraine-now)](https://github.com/support-ukraine/support-ukraine)

View File

@ -71,7 +71,7 @@ class CustomWorkflow < ApplicationRecord
Rails.logger.info "#{str} for #{object.class} (##{object.id}) \"#{object}\""
end
def self.run_shared_code(object)
def self.run_shared_code?(object)
# Due to DB migration
if CustomWorkflow.table_exists? && CustomWorkflow.active.exists?(observable: :shared)
log_message '= Running shared code', object
@ -86,7 +86,7 @@ class CustomWorkflow < ApplicationRecord
true
end
def self.run_custom_workflows(observable, object, event)
def self.run_custom_workflows?(observable, object, event)
if CustomWorkflow.table_exists? # Due to DB migration
workflows = CustomWorkflow.active.where(observable: observable)
if PROJECT_OBSERVABLES.include? observable
@ -153,12 +153,12 @@ class CustomWorkflow < ApplicationRecord
def validate_syntax
case observable.to_sym
when :shared
CustomWorkflow.run_shared_code self
CustomWorkflow.run_shared_code? self
validate_syntax_for self, :shared_code
when *SINGLE_OBSERVABLES
object = observable.camelize.constantize.new
object.send :instance_variable_set, "@#{observable}", object # compatibility with 0.0.1
CustomWorkflow.run_shared_code object
CustomWorkflow.run_shared_code? object
%i[before_save after_save before_destroy after_destroy].each { |field| validate_syntax_for object, field }
when *COLLECTION_OBSERVABLES
object = nil
@ -180,7 +180,7 @@ class CustomWorkflow < ApplicationRecord
object.send :instance_variable_set, :@attachment, Attachment.new
object.send :instance_variable_set, :@page, object
end
CustomWorkflow.run_shared_code object
CustomWorkflow.run_shared_code? object
%i[before_add after_add before_remove after_remove].each { |field| validate_syntax_for object, field }
end
end

View File

@ -26,7 +26,7 @@ Redmine::Plugin.register :redmine_custom_workflows do
author_url 'https://github.com/anteo/redmine_custom_workflows/graphs/contributors'
author 'Anton Argirov/Karel Pičman'
description 'It allows to create custom workflows for objects, defined in a plain Ruby language'
version '3.0.1'
version '3.0.2'
requires_redmine version_or_higher: '6.0.0'

View File

@ -42,8 +42,8 @@ module RedmineCustomWorkflows
def before_save_custom_workflows
@attachment = self
@saved_attributes = attributes.dup
CustomWorkflow.run_shared_code self
CustomWorkflow.run_custom_workflows :attachment, self, :before_save
CustomWorkflow.run_shared_code? self
CustomWorkflow.run_custom_workflows? :attachment, self, :before_save
throw :abort if errors.any?
errors.empty? && (@saved_attributes == attributes || valid?)
@ -52,16 +52,16 @@ module RedmineCustomWorkflows
end
def after_save_custom_workflows
CustomWorkflow.run_custom_workflows :attachment, self, :after_save
CustomWorkflow.run_custom_workflows? :attachment, self, :after_save
end
def before_destroy_custom_workflows
res = CustomWorkflow.run_custom_workflows :attachment, self, :before_destroy
res = CustomWorkflow.run_custom_workflows? :attachment, self, :before_destroy
throw :abort if res == false
end
def after_destroy_custom_workflows
CustomWorkflow.run_custom_workflows :attachment, self, :after_destroy
CustomWorkflow.run_custom_workflows? :attachment, self, :after_destroy
end
end
end

View File

@ -47,8 +47,8 @@ module RedmineCustomWorkflows
def self.users_callback(event, group, user)
group.instance_variable_set :@group, group
group.instance_variable_set :@user, user
CustomWorkflow.run_shared_code(group) if event.to_s.starts_with? 'before_'
CustomWorkflow.run_custom_workflows :group_users, group, event
CustomWorkflow.run_shared_code?(group) if event.to_s.starts_with? 'before_'
CustomWorkflow.run_custom_workflows? :group_users, group, event
end
%i[before_add before_remove after_add after_remove].each do |observable|
@ -62,8 +62,8 @@ module RedmineCustomWorkflows
def before_save_custom_workflows
@group = self
@saved_attributes = attributes.dup
CustomWorkflow.run_shared_code self
CustomWorkflow.run_custom_workflows :group, self, :before_save
CustomWorkflow.run_shared_code? self
CustomWorkflow.run_custom_workflows? :group, self, :before_save
throw :abort if errors.any?
errors.empty? && (@saved_attributes == attributes || valid?)
@ -72,16 +72,16 @@ module RedmineCustomWorkflows
end
def after_save_custom_workflows
CustomWorkflow.run_custom_workflows :group, self, :after_save
CustomWorkflow.run_custom_workflows? :group, self, :after_save
end
def before_destroy_custom_workflows
res = CustomWorkflow.run_custom_workflows :group, self, :before_destroy
res = CustomWorkflow.run_custom_workflows? :group, self, :before_destroy
throw :abort if res == false
end
def after_destroy_custom_workflows
CustomWorkflow.run_custom_workflows :group, self, :after_destroy
CustomWorkflow.run_custom_workflows? :group, self, :after_destroy
end
end
end

View File

@ -46,8 +46,8 @@ module RedmineCustomWorkflows
def self.attachments_callback(event, issue, attachment)
issue.instance_variable_set :@issue, issue
issue.instance_variable_set :@attachment, attachment
CustomWorkflow.run_shared_code(issue) if event.to_s.starts_with? 'before_'
CustomWorkflow.run_custom_workflows :issue_attachments, issue, event
CustomWorkflow.run_shared_code?(issue) if event.to_s.starts_with? 'before_'
CustomWorkflow.run_custom_workflows? :issue_attachments, issue, event
end
%i[before_add before_remove after_add after_remove].each do |observable|
@ -76,8 +76,8 @@ module RedmineCustomWorkflows
def before_save_custom_workflows
@issue = self
@saved_attributes = attributes.dup
CustomWorkflow.run_shared_code self
CustomWorkflow.run_custom_workflows :issue, self, :before_save
CustomWorkflow.run_shared_code? self
CustomWorkflow.run_custom_workflows? :issue, self, :before_save
throw :abort if errors.any?
errors.empty? && (@saved_attributes == attributes || valid?)
@ -86,16 +86,16 @@ module RedmineCustomWorkflows
end
def after_save_custom_workflows
CustomWorkflow.run_custom_workflows :issue, self, :after_save
CustomWorkflow.run_custom_workflows? :issue, self, :after_save
end
def before_destroy_custom_workflows
res = CustomWorkflow.run_custom_workflows(:issue, self, :before_destroy)
res = CustomWorkflow.run_custom_workflows?(:issue, self, :before_destroy)
throw :abort if res == false
end
def after_destroy_custom_workflows
CustomWorkflow.run_custom_workflows :issue, self, :after_destroy
CustomWorkflow.run_custom_workflows? :issue, self, :after_destroy
end
end
end

View File

@ -60,8 +60,8 @@ module RedmineCustomWorkflows
def before_save_custom_workflows
@issue_relation = self
@saved_attributes = attributes.dup
CustomWorkflow.run_shared_code self
CustomWorkflow.run_custom_workflows :issue_relation, self, :before_save
CustomWorkflow.run_shared_code? self
CustomWorkflow.run_custom_workflows? :issue_relation, self, :before_save
throw :abort if errors.any?
errors.empty? && (@saved_attributes == attributes || valid?)
ensure
@ -69,16 +69,16 @@ module RedmineCustomWorkflows
end
def after_save_custom_workflows
CustomWorkflow.run_custom_workflows :issue_relation, self, :after_save
CustomWorkflow.run_custom_workflows? :issue_relation, self, :after_save
end
def before_destroy_custom_workflows
res = CustomWorkflow.run_custom_workflows :issue_relation, self, :before_destroy
res = CustomWorkflow.run_custom_workflows? :issue_relation, self, :before_destroy
throw :abort if res == false
end
def after_destroy_custom_workflows
CustomWorkflow.run_custom_workflows :issue_relation, self, :after_destroy
CustomWorkflow.run_custom_workflows? :issue_relation, self, :after_destroy
end
end
end

View File

@ -42,8 +42,8 @@ module RedmineCustomWorkflows
def before_save_custom_workflows
@member = self
@saved_attributes = attributes.dup
CustomWorkflow.run_shared_code self
CustomWorkflow.run_custom_workflows :member, self, :before_save
CustomWorkflow.run_shared_code? self
CustomWorkflow.run_custom_workflows? :member, self, :before_save
throw :abort if errors.any?
errors.empty? && (@saved_attributes == attributes || valid?)
@ -52,16 +52,16 @@ module RedmineCustomWorkflows
end
def after_save_custom_workflows
CustomWorkflow.run_custom_workflows :member, self, :after_save
CustomWorkflow.run_custom_workflows? :member, self, :after_save
end
def before_destroy_custom_workflows
res = CustomWorkflow.run_custom_workflows :member, self, :before_destroy
res = CustomWorkflow.run_custom_workflows? :member, self, :before_destroy
throw :abort if res == false
end
def after_destroy_custom_workflows
CustomWorkflow.run_custom_workflows :member, self, :after_destroy
CustomWorkflow.run_custom_workflows? :member, self, :after_destroy
end
end
end

View File

@ -55,8 +55,8 @@ module RedmineCustomWorkflows
def self.attachments_callback(event, project, attachment)
project.instance_variable_set(:@project, project)
project.instance_variable_set(:@attachment, attachment)
CustomWorkflow.run_shared_code(project) if event.to_s.starts_with? 'before_'
CustomWorkflow.run_custom_workflows(:project_attachments, project, event)
CustomWorkflow.run_shared_code?(project) if event.to_s.starts_with? 'before_'
CustomWorkflow.run_custom_workflows?(:project_attachments, project, event)
end
%i[before_add before_remove after_add after_remove].each do |observable|
@ -70,8 +70,8 @@ module RedmineCustomWorkflows
def before_save_custom_workflows
@project = self
@saved_attributes = attributes.dup
CustomWorkflow.run_shared_code self
CustomWorkflow.run_custom_workflows :project, self, :before_save
CustomWorkflow.run_shared_code? self
CustomWorkflow.run_custom_workflows? :project, self, :before_save
throw :abort if errors.any?
errors.empty? && (@saved_attributes == attributes || valid?)
@ -80,16 +80,16 @@ module RedmineCustomWorkflows
end
def after_save_custom_workflows
CustomWorkflow.run_custom_workflows :project, self, :after_save
CustomWorkflow.run_custom_workflows? :project, self, :after_save
end
def before_destroy_custom_workflows
res = CustomWorkflow.run_custom_workflows :project, self, :before_destroy
res = CustomWorkflow.run_custom_workflows? :project, self, :before_destroy
throw :abort if res == false
end
def after_destroy_custom_workflows
CustomWorkflow.run_custom_workflows :project, self, :after_destroy
CustomWorkflow.run_custom_workflows? :project, self, :after_destroy
end
end
end

View File

@ -42,8 +42,8 @@ module RedmineCustomWorkflows
def before_save_custom_workflows
@time_entry = self
@saved_attributes = attributes.dup
CustomWorkflow.run_shared_code(self)
CustomWorkflow.run_custom_workflows(:time_entry, self, :before_save)
CustomWorkflow.run_shared_code?(self)
CustomWorkflow.run_custom_workflows?(:time_entry, self, :before_save)
throw :abort if errors.any?
errors.empty? && (@saved_attributes == attributes || valid?)
@ -52,16 +52,16 @@ module RedmineCustomWorkflows
end
def after_save_custom_workflows
CustomWorkflow.run_custom_workflows :time_entry, self, :after_save
CustomWorkflow.run_custom_workflows? :time_entry, self, :after_save
end
def before_destroy_custom_workflows
res = CustomWorkflow.run_custom_workflows :time_entry, self, :before_destroy
res = CustomWorkflow.run_custom_workflows? :time_entry, self, :before_destroy
throw :abort if res == false
end
def after_destroy_custom_workflows
CustomWorkflow.run_custom_workflows :time_entry, self, :after_destroy
CustomWorkflow.run_custom_workflows? :time_entry, self, :after_destroy
end
end
end

View File

@ -42,8 +42,8 @@ module RedmineCustomWorkflows
def before_save_custom_workflows
@user = self
@saved_attributes = attributes.dup
CustomWorkflow.run_shared_code self
CustomWorkflow.run_custom_workflows :user, self, :before_save
CustomWorkflow.run_shared_code? self
CustomWorkflow.run_custom_workflows? :user, self, :before_save
throw :abort if errors.any?
errors.empty? && (@saved_attributes == attributes || valid?)
@ -52,16 +52,16 @@ module RedmineCustomWorkflows
end
def after_save_custom_workflows
CustomWorkflow.run_custom_workflows :user, self, :after_save
CustomWorkflow.run_custom_workflows? :user, self, :after_save
end
def before_destroy_custom_workflows
res = CustomWorkflow.run_custom_workflows :user, self, :before_destroy
res = CustomWorkflow.run_custom_workflows? :user, self, :before_destroy
throw :abort if res == false
end
def after_destroy_custom_workflows
CustomWorkflow.run_custom_workflows :user, self, :after_destroy
CustomWorkflow.run_custom_workflows? :user, self, :after_destroy
end
end
end

View File

@ -42,8 +42,8 @@ module RedmineCustomWorkflows
def before_save_custom_workflows
@version = self
@saved_attributes = attributes.dup
CustomWorkflow.run_shared_code self
CustomWorkflow.run_custom_workflows :version, self, :before_save
CustomWorkflow.run_shared_code? self
CustomWorkflow.run_custom_workflows? :version, self, :before_save
throw :abort if errors.any?
errors.empty? && (@saved_attributes == attributes || valid?)
@ -52,16 +52,16 @@ module RedmineCustomWorkflows
end
def after_save_custom_workflows
CustomWorkflow.run_custom_workflows :version, self, :after_save
CustomWorkflow.run_custom_workflows? :version, self, :after_save
end
def before_destroy_custom_workflows
res = CustomWorkflow.run_custom_workflows :version, self, :before_destroy
res = CustomWorkflow.run_custom_workflows? :version, self, :before_destroy
throw :abort if res == false
end
def after_destroy_custom_workflows
CustomWorkflow.run_custom_workflows :version, self, :after_destroy
CustomWorkflow.run_custom_workflows? :version, self, :after_destroy
end
end
end

View File

@ -42,8 +42,8 @@ module RedmineCustomWorkflows
def before_save_custom_workflows
@content = self
@saved_attributes = attributes.dup
CustomWorkflow.run_shared_code self
CustomWorkflow.run_custom_workflows :wiki_content, self, :before_save
CustomWorkflow.run_shared_code? self
CustomWorkflow.run_custom_workflows? :wiki_content, self, :before_save
throw :abort if errors.any?
errors.empty? && (@saved_attributes == attributes || valid?)
@ -52,16 +52,16 @@ module RedmineCustomWorkflows
end
def after_save_custom_workflows
CustomWorkflow.run_custom_workflows :wiki_content, self, :after_save
CustomWorkflow.run_custom_workflows? :wiki_content, self, :after_save
end
def before_destroy_custom_workflows
res = CustomWorkflow.run_custom_workflows :wiki_content, self, :before_destroy
res = CustomWorkflow.run_custom_workflows? :wiki_content, self, :before_destroy
throw :abort if res == false
end
def after_destroy_custom_workflows
CustomWorkflow.run_custom_workflows :wiki_content, self, :after_destroy
CustomWorkflow.run_custom_workflows? :wiki_content, self, :after_destroy
end
end
end

View File

@ -41,8 +41,8 @@ module RedmineCustomWorkflows
def self.attachments_callback(event, page, attachment)
page.instance_variable_set :@page, page
page.instance_variable_set :@attachment, attachment
CustomWorkflow.run_shared_code(page) if event.to_s.starts_with? 'before_'
CustomWorkflow.run_custom_workflows :wiki_page_attachments, page, event
CustomWorkflow.run_shared_code?(page) if event.to_s.starts_with? 'before_'
CustomWorkflow.run_custom_workflows? :wiki_page_attachments, page, event
end
%i[before_add before_remove after_add after_remove].each do |observable|

View File

@ -21,9 +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
@attachment8 = Attachment.find 8

View File

@ -21,8 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
# Custom workflows controller test
class CustomWorkflowsControllerTest < RedmineCustomWorkflows::Test::TestCase
fixtures :custom_workflows
def setup
super
@cw1 = CustomWorkflow.find 1

View File

@ -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

View File

@ -21,10 +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
@ir1 = IssueRelation.find 1

View File

@ -21,10 +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
@issue1 = Issue.find 1

View File

@ -21,8 +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
@member1 = Member.find 1

View File

@ -21,9 +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
post '/login', params: { username: 'jsmith', password: 'jsmith' }

View File

@ -21,10 +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
@te1 = TimeEntry.find 1

View File

@ -21,8 +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
post '/login', params: { username: 'admin', password: 'admin' }

View File

@ -21,8 +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
@version1 = Version.find 1

View File

@ -21,10 +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
@wp1 = WikiPage.find 1

View File

@ -21,22 +21,15 @@ 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
# 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

View File

@ -21,8 +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
end

View File

@ -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

View File

@ -21,8 +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
end

View File

@ -21,8 +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
end

View File

@ -21,8 +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
end

View File

@ -21,8 +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
end

View File

@ -21,8 +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
end

View File

@ -21,8 +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
end

View File

@ -21,8 +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
end

View File

@ -21,8 +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
end

View File

@ -21,8 +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
end

View File

@ -21,8 +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
end

View File

@ -21,8 +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
end

View File

@ -21,15 +21,15 @@ 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
# 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