mirror of
https://github.com/anteo/redmine_custom_workflows.git
synced 2026-01-26 00:04:20 +00:00
#39 Ability to raise a warning or info
This commit is contained in:
parent
6fb3229ad6
commit
fc02901151
128
README.md
128
README.md
@ -6,24 +6,33 @@ Custom Workflows plug-in 2.0.6 devel
|
||||
|
||||
This plug-in provides a great functionality for those who is familiar with the Ruby language.
|
||||
It allows to customize workflow by defining own rules for issues processing. It's possible:
|
||||
|
||||
* To change issue properties if some conditions are met.
|
||||
* To create new issues programmatically, if the conditions are met (for example you can create an issue in another project if the status of source issue is changed to specific value).
|
||||
* To create new issues programmatically, if the conditions are met (for example you can create an issue in another
|
||||
project if the status of source issue is changed to specific value).
|
||||
* To raise custom errors which will be displayed to the user, if he does something wrong.
|
||||
* To do anything that conforms to your needs.
|
||||
|
||||
Supported observable objects:
|
||||
* Issue (before_save, after_save)
|
||||
* Group (before_save, after_save)
|
||||
* User (before_save, after_save)
|
||||
* Group users (before_add, after_add, before_remove, after_remove)
|
||||
|
||||
* Attachment
|
||||
* Group
|
||||
* Issue
|
||||
* Issue relations
|
||||
* Time entry
|
||||
* User
|
||||
* Version
|
||||
* Wiki
|
||||
* \<Shared code\>
|
||||
|
||||
`<Shared code>` - special type for workflows that running before all other workflows and can provide libraries of additional functions or classes.
|
||||
`<Shared code>` - a special type for workflows that are running before all other workflows and can provide libraries of
|
||||
additional functions or classes.
|
||||
|
||||
Thanks to
|
||||
---------
|
||||
|
||||
The initial development was supported by [DOM Digital Online Media GmbH](https://www.dom.de). The present development is supported by [Kontron](https://www.kontorn.com)
|
||||
The initial development was supported by [DOM Digital Online Media GmbH](https://www.dom.de). The present development
|
||||
is supported by [Kontron](https://www.kontron.com)
|
||||
|
||||
Getting help
|
||||
------------
|
||||
@ -71,70 +80,105 @@ systemctl restart apache2
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
First, you need to define your own custom workflow(s). We already included one, called "Duration/Done Ratio/Status correlation". You'll find it after installing the plug-in. It demonstrates some possibilities of plug-in.
|
||||
First, you need to define your own custom workflow(s). We already included one, called "Duration/Done Ratio/Status
|
||||
correlation". You'll find it after installing the plug-in. It demonstrates some possibilities of the plug-in.
|
||||
|
||||
Go to the *Administration* section, then select <b>Custom workflows</b>. A list of defined workflows will appear. Here you can create new workflow, update, reorder and delete existing workflows. The order of workflows specifies the order in which workflow scripts will be executed.
|
||||
Go to the **_Administration_** section, then select **_Custom workflows_**. A list of defined workflows will appear. Here
|
||||
you can create a new workflow, update, reorder or delete the existing workflows. The order of workflows specifies the
|
||||
order in which the workflow scripts will be executed.
|
||||
|
||||
Then click the <b>Create a custom workflow</b> button. Enter a short name and full description. Below you will see two textareas. Fill one or both textareas by Ruby-language scripts that will be executed before and after saving the issue (on before_save and after_save callbacks respectively).
|
||||
Then click the **Create a custom workflow** button. Enter a short name and full description. Below you will see two text
|
||||
areas. Fill one or both text areas with Ruby-language scripts that will be executed before and after saving the issue
|
||||
(on _before_save_ and _after_save_ callbacks respectively).
|
||||
|
||||
Both scripts are executed in the context of the issue. So access properties and methods of the issue directly (or through keyword "self"). You can also raise exceptions by <b>raise RedmineCustomWorkflows::Errors::WorkflowError, "Your message"</b>. If you change some properties of the issue before saving it, it will be revalidated then and additional validation errors can appear.
|
||||
Both scripts are executed in the context of the issue. So, access properties and methods of the issue directly (or
|
||||
through keyword `self`). You can also raise exceptions by raising `RedmineCustomWorkflows::Errors::WorkflowError` exception.
|
||||
If you change some properties of the issue before saving it, it will be revalidated then and additional validation errors
|
||||
can appear.
|
||||
|
||||
E.g.:
|
||||
|
||||
```ruby
|
||||
raise RedmineCustomWorkflows::Errors::WorkflowError, 'Your message'
|
||||
```
|
||||
|
||||
You can also display an info/warning/error message to the user using an observed object property `custom_workflow_messages`.
|
||||
|
||||
E.g.:
|
||||
|
||||
```ruby
|
||||
self.custom_workflow_messages[:notice] = 'Custom workflow info'
|
||||
self.custom_workflow_messages[:warning] = 'Custom workflow warning'
|
||||
self.custom_workflow_messages[:error] = 'Custom workflow error'
|
||||
```
|
||||
|
||||
Enabling custom workflows for projects
|
||||
-------------------------------
|
||||
--------------------------------------
|
||||
|
||||
After you defined your custom workflow(s), you need to enable it for particular project(s). There are two ways of doing this.
|
||||
* While editing existing or creating new custom workflow;
|
||||
* In project settings (if the user has appropriate permission). Open <b>Project settings</b>. Go to the <b>Custom workflows</b> tab of the project settings and enable workflow(s) you need for this project.
|
||||
After you defined your custom workflow(s), you need to enable it for particular project(s). (This is valid for project
|
||||
related observable objects.) There are two ways of doing
|
||||
this.
|
||||
* While editing existing or creating a new custom workflow;
|
||||
* In the project's settings (if the user has appropriate permission). Open **_Project settings_**. Go to
|
||||
**_Custom workflows_** tab of the project's settings and enable those workflows you need for this project.
|
||||
|
||||
Now go to the *Issues* and test it.
|
||||
Now go to the **_Issues_** and test it.
|
||||
|
||||
Duration/Done Ratio/Status correlation example
|
||||
----------------------------------------------
|
||||
Examples
|
||||
--------
|
||||
|
||||
### Duration/Done Ratio/Status correlation example
|
||||
|
||||
Fill the "before save" script with:
|
||||
|
||||
if done_ratio_changed?
|
||||
if done_ratio==100 && status_id==2
|
||||
self.status_id=3
|
||||
elsif [1,3,4].include?(status_id) && done_ratio<100
|
||||
self.status_id=2
|
||||
end
|
||||
```ruby
|
||||
if done_ratio_changed?
|
||||
if (done_ratio == 100) && (status_id == 2)
|
||||
self.status_id = 3
|
||||
elsif [1,3,4].include?(status_id) && (done_ratio < 100)
|
||||
self.status_id = 2
|
||||
end
|
||||
end
|
||||
|
||||
if status_id_changed?
|
||||
if status_id==2
|
||||
if status_id_changed?
|
||||
if (status_id == 2)
|
||||
self.start_date ||= Time.now
|
||||
end
|
||||
if status_id==3
|
||||
if (status_id == 3)
|
||||
self.done_ratio = 100
|
||||
self.start_date ||= created_on
|
||||
self.due_date ||= Time.now
|
||||
end
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
Example of creating subtask if the issue's status has changed
|
||||
-------------------------------------------------------------
|
||||
### Example of creating subtask if the issue's status has changed
|
||||
|
||||
Fill the "before save" script with:
|
||||
|
||||
@need_create = status_id_changed? && !new_record?
|
||||
```ruby
|
||||
@need_create = status_id_changed? && !new_record?
|
||||
```
|
||||
|
||||
Fill the "after save" script with:
|
||||
|
||||
if @need_create
|
||||
```ruby
|
||||
if @need_create
|
||||
issue = Issue.new(
|
||||
:author => User.current,
|
||||
:project => project,
|
||||
:tracker => tracker,
|
||||
:assigned_to => author,
|
||||
:parent_issue_id => id,
|
||||
:subject => "Subtask",
|
||||
:description => "Description")
|
||||
|
||||
author: User.current,
|
||||
project: project,
|
||||
tracker: tracker,
|
||||
assigned_to: author,
|
||||
parent_issue_id: id,
|
||||
subject: 'Subtask',
|
||||
description: 'Description')
|
||||
issue.save!
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
Do not forget to check whether issue is just created. Here we create the new issue and newly created issue will also be passed to this script on save. So without check, it will create another sub-issue. And etc. Thus it will fall into infinite recursion.
|
||||
Do not forget to check whether the issue is just created. Here, we create a new issue and newly created issue will also
|
||||
be passed to this script on save event. So, without a check, it will create another sub-issue. And so on. Thus, it will
|
||||
fall into infinite loop.
|
||||
|
||||
Compatibility
|
||||
-------------
|
||||
|
||||
@ -41,6 +41,8 @@ class CustomWorkflow < ActiveRecord::Base
|
||||
where("is_for_all=? OR EXISTS (SELECT * FROM #{reflect_on_association(:projects).join_table} WHERE project_id=? AND custom_workflow_id=id)",
|
||||
true, project.id)
|
||||
end)
|
||||
#scope :for_project, (lambda { |project| where(is_for_all: true).or(where(
|
||||
# 'SELECT * FROM custom_workflow_projects WHERE project_id = ? AND custom_workflow_id = id', project.id).exists?) })
|
||||
|
||||
def self.import_from_xml(xml)
|
||||
attributes = Hash.from_xml(xml).values.first
|
||||
@ -162,20 +164,17 @@ class CustomWorkflow < ActiveRecord::Base
|
||||
object.send :instance_variable_set, :@page, object
|
||||
end
|
||||
CustomWorkflow.run_shared_code object
|
||||
[:before_add, :after_add, :before_remove, :after_remove].each {|field| validate_syntax_for object, field}
|
||||
[:before_add, :after_add, :before_remove, :after_remove].each { |field| validate_syntax_for object, field }
|
||||
end
|
||||
end
|
||||
|
||||
def export_as_xml
|
||||
only = [:author, :name, :description, :before_save, :after_save, :shared_code, :observable,
|
||||
:before_add, :after_add, :before_remove, :after_remove, :before_destroy, :after_destroy, :created_at]
|
||||
only = only.select { |p| self[p] }
|
||||
to_xml :only => only do |xml|
|
||||
xml.tag! 'exported-at', Time.current.xmlschema
|
||||
xml.tag! 'plugin-version', Redmine::Plugin.find(:redmine_custom_workflows).version
|
||||
xml.tag! 'ruby-version', "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
|
||||
xml.tag! 'rails-version', Rails::VERSION::STRING
|
||||
end
|
||||
attrs = self.attributes.dup
|
||||
attrs['exported-at'] = Time.current.xmlschema
|
||||
attrs['plugin-version'] = Redmine::Plugin.find(:redmine_custom_workflows).version
|
||||
attrs['ruby-version'] = "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
|
||||
attrs['rails-version'] = Rails::VERSION::STRING
|
||||
attrs.to_xml
|
||||
end
|
||||
|
||||
def <=>(other)
|
||||
@ -185,4 +184,5 @@ class CustomWorkflow < ActiveRecord::Base
|
||||
def to_s
|
||||
name
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -27,14 +27,29 @@ require File.dirname(__FILE__) + '/redmine_custom_workflows/hooks/views/base_vie
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/errors/workflow_error'
|
||||
|
||||
# Patches
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/attachment_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/group_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/issue_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/issue_relation_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/project_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/projects_helper_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/time_entry_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/user_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/version_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/wiki_content_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/wiki_page_patch'
|
||||
|
||||
# Models
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/models/attachment_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/models/group_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/models/issue_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/models/issue_relation_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/models/project_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/models/time_entry_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/models/user_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/models/version_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/models/wiki_content_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/models/wiki_page_patch'
|
||||
|
||||
# Controllers
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/controllers/issues_controller_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/controllers/attachments_controller_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/controllers/groups_controller_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/controllers/issue_relations_controller_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/controllers/projects_controller_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/controllers/timelog_controller_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/controllers/users_controller_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/controllers/versions_controller_patch'
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/controllers/wiki_controller_patch'
|
||||
|
||||
# Helpers
|
||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/helpers/projects_helper_patch'
|
||||
|
||||
@ -1,68 +0,0 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module AttachmentPatch
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
before_save :before_save_custom_workflows
|
||||
after_save :after_save_custom_workflows
|
||||
before_destroy :before_destroy_custom_workflows
|
||||
after_destroy :after_destroy_custom_workflows
|
||||
end
|
||||
end
|
||||
|
||||
def before_save_custom_workflows
|
||||
@attachment = self
|
||||
@saved_attributes = attributes.dup
|
||||
CustomWorkflow.run_shared_code self
|
||||
CustomWorkflow.run_custom_workflows :attachment, self, :before_save
|
||||
throw :abort if errors.any?
|
||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||
ensure
|
||||
@saved_attributes = nil
|
||||
end
|
||||
|
||||
def after_save_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :attachment, self, :after_save
|
||||
end
|
||||
|
||||
def before_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :attachment, self, :before_destroy
|
||||
end
|
||||
|
||||
def after_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :attachment, self, :after_destroy
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
RedmineExtensions::PatchManager.register_model_patch 'Attachment', 'RedmineCustomWorkflows::Patches::AttachmentPatch'
|
||||
else
|
||||
Attachment.prepend RedmineCustomWorkflows::Patches::AttachmentPatch
|
||||
end
|
||||
@ -0,0 +1,65 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module Controllers
|
||||
module AttachmentsControllerPatch
|
||||
|
||||
################################################################################################################
|
||||
# New methods
|
||||
#
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
after_action :display_custom_workflow_messages
|
||||
end
|
||||
end
|
||||
|
||||
def display_custom_workflow_messages
|
||||
if @attachments
|
||||
objects = @attachments
|
||||
elsif @attachment
|
||||
objects = [@attachment]
|
||||
end
|
||||
if objects&.any?
|
||||
objects.each do |o|
|
||||
if o&.custom_workflow_messages&.any?
|
||||
o.custom_workflow_messages.each do |key, value|
|
||||
if value.empty?
|
||||
flash.delete key
|
||||
else
|
||||
flash[key] = value
|
||||
end
|
||||
end
|
||||
o.custom_workflow_messages = {}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
AttachmentsController.send :prepend, RedmineCustomWorkflows::Patches::Controllers::AttachmentsControllerPatch
|
||||
@ -0,0 +1,65 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module Controllers
|
||||
module GroupsControllerPatch
|
||||
|
||||
################################################################################################################
|
||||
# New methods
|
||||
#
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
after_action :display_custom_workflow_messages
|
||||
end
|
||||
end
|
||||
|
||||
def display_custom_workflow_messages
|
||||
if @groups
|
||||
objects = @groups
|
||||
elsif @group
|
||||
objects = [@group]
|
||||
end
|
||||
if objects&.any?
|
||||
objects.each do |o|
|
||||
if o&.custom_workflow_messages&.any?
|
||||
o.custom_workflow_messages.each do |key, value|
|
||||
if value.empty?
|
||||
flash.delete key
|
||||
else
|
||||
flash[key] = value
|
||||
end
|
||||
end
|
||||
o.custom_workflow_messages = {}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
GroupsController.send :prepend, RedmineCustomWorkflows::Patches::Controllers::GroupsControllerPatch
|
||||
@ -0,0 +1,65 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module Controllers
|
||||
module IssueRelationsControllerPatch
|
||||
|
||||
################################################################################################################
|
||||
# New methods
|
||||
#
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
after_action :display_custom_workflow_messages
|
||||
end
|
||||
end
|
||||
|
||||
def display_custom_workflow_messages
|
||||
if @relations
|
||||
objects = @relations
|
||||
elsif @relation
|
||||
objects = [@relation]
|
||||
end
|
||||
if objects&.any?
|
||||
objects.each do |o|
|
||||
if o&.custom_workflow_messages&.any?
|
||||
o.custom_workflow_messages.each do |key, value|
|
||||
if value.empty?
|
||||
flash.delete key
|
||||
else
|
||||
flash[key] = value
|
||||
end
|
||||
end
|
||||
o.custom_workflow_messages = {}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
IssueRelationsController.send :prepend, RedmineCustomWorkflows::Patches::Controllers::IssueRelationsControllerPatch
|
||||
@ -0,0 +1,65 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module Controllers
|
||||
module IssuesControllerPatch
|
||||
|
||||
################################################################################################################
|
||||
# New methods
|
||||
#
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
after_action :display_custom_workflow_messages
|
||||
end
|
||||
end
|
||||
|
||||
def display_custom_workflow_messages
|
||||
if @issues
|
||||
objects = @issues
|
||||
elsif @issue
|
||||
objects = [@issue]
|
||||
end
|
||||
if objects&.any?
|
||||
objects.each do |o|
|
||||
if o&.custom_workflow_messages&.any?
|
||||
o.custom_workflow_messages.each do |key, value|
|
||||
if value.empty?
|
||||
flash.delete key
|
||||
else
|
||||
flash[key] = value
|
||||
end
|
||||
end
|
||||
o.custom_workflow_messages = {}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
IssuesController.send :prepend, RedmineCustomWorkflows::Patches::Controllers::IssuesControllerPatch
|
||||
@ -0,0 +1,65 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module Controllers
|
||||
module ProjectsControllerPatch
|
||||
|
||||
################################################################################################################
|
||||
# New methods
|
||||
#
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
after_action :display_custom_workflow_messages
|
||||
end
|
||||
end
|
||||
|
||||
def display_custom_workflow_messages
|
||||
if @projects
|
||||
objects = @projects
|
||||
elsif @project
|
||||
objects = [@project]
|
||||
end
|
||||
if objects&.any?
|
||||
objects.each do |o|
|
||||
if o&.custom_workflow_messages&.any?
|
||||
o.custom_workflow_messages.each do |key, value|
|
||||
if value.empty?
|
||||
flash.delete key
|
||||
else
|
||||
flash[key] = value
|
||||
end
|
||||
end
|
||||
o.custom_workflow_messages = {}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ProjectsController.send :prepend, RedmineCustomWorkflows::Patches::Controllers::ProjectsControllerPatch
|
||||
@ -0,0 +1,65 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module Controllers
|
||||
module TimelogControllerPatch
|
||||
|
||||
################################################################################################################
|
||||
# New methods
|
||||
#
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
after_action :display_custom_workflow_messages
|
||||
end
|
||||
end
|
||||
|
||||
def display_custom_workflow_messages
|
||||
if @time_entries
|
||||
objects = @time_entries
|
||||
elsif @time_entry
|
||||
objects = [@time_entry]
|
||||
end
|
||||
if objects&.any?
|
||||
objects.each do |o|
|
||||
if o&.custom_workflow_messages&.any?
|
||||
o.custom_workflow_messages.each do |key, value|
|
||||
if value.empty?
|
||||
flash.delete key
|
||||
else
|
||||
flash[key] = value
|
||||
end
|
||||
end
|
||||
o.custom_workflow_messages = {}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
TimelogController.send :prepend, RedmineCustomWorkflows::Patches::Controllers::TimelogControllerPatch
|
||||
@ -0,0 +1,65 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module Controllers
|
||||
module UsersControllerPatch
|
||||
|
||||
################################################################################################################
|
||||
# New methods
|
||||
#
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
after_action :display_custom_workflow_messages
|
||||
end
|
||||
end
|
||||
|
||||
def display_custom_workflow_messages
|
||||
if @users
|
||||
objects = @users
|
||||
elsif @user
|
||||
objects = [@user]
|
||||
end
|
||||
if objects&.any?
|
||||
objects.each do |o|
|
||||
if o&.custom_workflow_messages&.any?
|
||||
o.custom_workflow_messages.each do |key, value|
|
||||
if value.empty?
|
||||
flash.delete key
|
||||
else
|
||||
flash[key] = value
|
||||
end
|
||||
end
|
||||
o.custom_workflow_messages = {}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
UsersController.send :prepend, RedmineCustomWorkflows::Patches::Controllers::UsersControllerPatch
|
||||
@ -0,0 +1,65 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module Controllers
|
||||
module VersionsControllerPatch
|
||||
|
||||
################################################################################################################
|
||||
# New methods
|
||||
#
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
after_action :display_custom_workflow_messages
|
||||
end
|
||||
end
|
||||
|
||||
def display_custom_workflow_messages
|
||||
if @versions
|
||||
objects = @versions
|
||||
elsif @version
|
||||
objects = [@version]
|
||||
end
|
||||
if objects&.any?
|
||||
objects.each do |o|
|
||||
if o&.custom_workflow_messages&.any?
|
||||
o.custom_workflow_messages.each do |key, value|
|
||||
if value.empty?
|
||||
flash.delete key
|
||||
else
|
||||
flash[key] = value
|
||||
end
|
||||
end
|
||||
o.custom_workflow_messages = {}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
VersionsController.send :prepend, RedmineCustomWorkflows::Patches::Controllers::VersionsControllerPatch
|
||||
@ -0,0 +1,69 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module Controllers
|
||||
module WikiControllerPatch
|
||||
|
||||
################################################################################################################
|
||||
# New methods
|
||||
#
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
after_action :display_custom_workflow_messages
|
||||
end
|
||||
end
|
||||
|
||||
def display_custom_workflow_messages
|
||||
if @pages
|
||||
objects = @pages
|
||||
elsif @page
|
||||
objects = [@page]
|
||||
end
|
||||
if @content
|
||||
objects ||= []
|
||||
objects << @content
|
||||
end
|
||||
if objects&.any?
|
||||
objects.each do |o|
|
||||
if o&.custom_workflow_messages&.any?
|
||||
o.custom_workflow_messages.each do |key, value|
|
||||
if value.empty?
|
||||
flash.delete key
|
||||
else
|
||||
flash[key] = value
|
||||
end
|
||||
end
|
||||
o.custom_workflow_messages = {}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
WikiController.send :prepend, RedmineCustomWorkflows::Patches::Controllers::WikiControllerPatch
|
||||
@ -1,83 +0,0 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module GroupPatch
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
before_save :before_save_custom_workflows
|
||||
after_save :after_save_custom_workflows
|
||||
before_destroy :before_destroy_custom_workflows
|
||||
after_destroy :after_destroy_custom_workflows
|
||||
|
||||
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
|
||||
end
|
||||
[:before_add, :before_remove, :after_add, :after_remove].each do |observable|
|
||||
send("#{observable}_for_users") << if Rails::VERSION::MAJOR >= 4
|
||||
lambda { |event, group, user| Group.users_callback(event, group, user) }
|
||||
else
|
||||
lambda { |group, user| Group.users_callback(observable, group, user) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def before_save_custom_workflows
|
||||
@group = self
|
||||
@saved_attributes = attributes.dup
|
||||
CustomWorkflow.run_shared_code self
|
||||
CustomWorkflow.run_custom_workflows :group, self, :before_save
|
||||
throw :abort if errors.any?
|
||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||
ensure
|
||||
@saved_attributes = nil
|
||||
end
|
||||
|
||||
def after_save_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :group, self, :after_save
|
||||
end
|
||||
|
||||
def before_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :group, self, :before_destroy
|
||||
end
|
||||
|
||||
def after_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :group, self, :after_destroy
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
RedmineExtensions::PatchManager.register_model_patch 'Group',
|
||||
'RedmineCustomWorkflows::Patches::GroupPatch'
|
||||
else
|
||||
Group.prepend RedmineCustomWorkflows::Patches::GroupPatch
|
||||
end
|
||||
@ -22,6 +22,7 @@
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module Helpers
|
||||
module ProjectsHelperPatch
|
||||
|
||||
def project_settings_tabs
|
||||
@ -33,12 +34,13 @@ module RedmineCustomWorkflows
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
RedmineExtensions::PatchManager.register_helper_patch 'ProjectsHelper',
|
||||
'RedmineCustomWorkflows::Patches::ProjectsHelperPatch', prepend: true
|
||||
'RedmineCustomWorkflows::Patches::Helpers::ProjectsHelperPatch', prepend: true
|
||||
else
|
||||
ProjectsController.send :helper, RedmineCustomWorkflows::Patches::ProjectsHelperPatch
|
||||
ProjectsController.send :helper, RedmineCustomWorkflows::Patches::Helpers::ProjectsHelperPatch
|
||||
end
|
||||
@ -1,91 +0,0 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module IssueRelationPatch
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
before_save :before_save_custom_workflows
|
||||
after_save :after_save_custom_workflows
|
||||
before_destroy :before_destroy_custom_workflows
|
||||
after_destroy :after_destroy_custom_workflows
|
||||
end
|
||||
|
||||
base.prepend InstanceMethods
|
||||
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
|
||||
################################################################################################################
|
||||
# Overriden methods
|
||||
|
||||
# Override IssueRelation.to_s to rescue NoMethodError during CustomWorkflow.validate_syntax due to
|
||||
# logging of temporarily instatiated IssueRelation with no related issues set.
|
||||
def to_s(issue=nil)
|
||||
super
|
||||
rescue NoMethodError => e
|
||||
if issue_from.present? || issue_to.present?
|
||||
raise e
|
||||
end
|
||||
end
|
||||
|
||||
################################################################################################################
|
||||
# New methods
|
||||
|
||||
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
|
||||
throw :abort if errors.any?
|
||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||
ensure
|
||||
@saved_attributes = nil
|
||||
end
|
||||
|
||||
def after_save_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :issue_relation, self, :after_save
|
||||
end
|
||||
|
||||
def before_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :issue_relation, self, :before_destroy
|
||||
end
|
||||
|
||||
def after_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :issue_relation, self, :after_destroy
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
RedmineExtensions::PatchManager.register_model_patch 'IssueRelation', 'RedmineCustomWorkflows::Patches::IssueRelationPatch'
|
||||
else
|
||||
IssueRelation.prepend RedmineCustomWorkflows::Patches::IssueRelationPatch
|
||||
end
|
||||
@ -1,59 +0,0 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module MailerPatch
|
||||
|
||||
def self.deliver_custom_email(headers={})
|
||||
user = headers.delete :user
|
||||
headers[:to] = user.mail if user
|
||||
text_body = headers.delete :text_body
|
||||
html_body = headers.delete :html_body
|
||||
template_name = headers.delete :template_name
|
||||
template_params = headers.delete(:template_params) || {}
|
||||
if text_body || html_body
|
||||
mail headers do |format|
|
||||
format.text { render text: text_body } if text_body
|
||||
format.html { render text: html_body } if html_body
|
||||
end
|
||||
elsif template_name
|
||||
template_params.each { |k,v| instance_variable_set("@#{k}", v) }
|
||||
mail headers do |format|
|
||||
format.text { render template_name }
|
||||
format.html { render template_name } unless Setting.plain_text_mail?
|
||||
end
|
||||
else
|
||||
raise StandardError.new('Not :text_body, :html_body or :template_name specified')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
RedmineExtensions::PatchManager.register_model_patch 'Mailer', 'RedmineCustomWorkflows::Patches::MailerPatch'
|
||||
else
|
||||
Mailer.prepend RedmineCustomWorkflows::Patches::MailerPatch
|
||||
end
|
||||
@ -0,0 +1,77 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module Models
|
||||
module AttachmentPatch
|
||||
|
||||
attr_accessor 'custom_workflow_messages'
|
||||
|
||||
def custom_workflow_messages
|
||||
@custom_workflow_messages ||= {}
|
||||
end
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
before_save :before_save_custom_workflows
|
||||
after_save :after_save_custom_workflows
|
||||
before_destroy :before_destroy_custom_workflows
|
||||
after_destroy :after_destroy_custom_workflows
|
||||
end
|
||||
end
|
||||
|
||||
def before_save_custom_workflows
|
||||
@attachment = self
|
||||
@saved_attributes = attributes.dup
|
||||
CustomWorkflow.run_shared_code self
|
||||
CustomWorkflow.run_custom_workflows :attachment, self, :before_save
|
||||
throw :abort if errors.any?
|
||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||
ensure
|
||||
@saved_attributes = nil
|
||||
end
|
||||
|
||||
def after_save_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :attachment, self, :after_save
|
||||
end
|
||||
|
||||
def before_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :attachment, self, :before_destroy
|
||||
end
|
||||
|
||||
def after_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :attachment, self, :after_destroy
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
RedmineExtensions::PatchManager.register_model_patch 'Attachment',
|
||||
'RedmineCustomWorkflows::Patches::Models::AttachmentPatch'
|
||||
else
|
||||
Attachment.prepend RedmineCustomWorkflows::Patches::Models::AttachmentPatch
|
||||
end
|
||||
91
lib/redmine_custom_workflows/patches/models/group_patch.rb
Normal file
91
lib/redmine_custom_workflows/patches/models/group_patch.rb
Normal file
@ -0,0 +1,91 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module Models
|
||||
module GroupPatch
|
||||
|
||||
attr_accessor 'custom_workflow_messages'
|
||||
|
||||
def custom_workflow_messages
|
||||
@custom_workflow_messages ||= {}
|
||||
end
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
before_save :before_save_custom_workflows
|
||||
after_save :after_save_custom_workflows
|
||||
before_destroy :before_destroy_custom_workflows
|
||||
after_destroy :after_destroy_custom_workflows
|
||||
|
||||
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
|
||||
end
|
||||
[:before_add, :before_remove, :after_add, :after_remove].each do |observable|
|
||||
send("#{observable}_for_users") << if Rails::VERSION::MAJOR >= 4
|
||||
lambda { |event, group, user| Group.users_callback(event, group, user) }
|
||||
else
|
||||
lambda { |group, user| Group.users_callback(observable, group, user) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def before_save_custom_workflows
|
||||
@group = self
|
||||
@saved_attributes = attributes.dup
|
||||
CustomWorkflow.run_shared_code self
|
||||
CustomWorkflow.run_custom_workflows :group, self, :before_save
|
||||
throw :abort if errors.any?
|
||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||
ensure
|
||||
@saved_attributes = nil
|
||||
end
|
||||
|
||||
def after_save_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :group, self, :after_save
|
||||
end
|
||||
|
||||
def before_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :group, self, :before_destroy
|
||||
end
|
||||
|
||||
def after_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :group, self, :after_destroy
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
RedmineExtensions::PatchManager.register_model_patch 'Group',
|
||||
'RedmineCustomWorkflows::Patches::Models::GroupPatch'
|
||||
else
|
||||
Group.prepend RedmineCustomWorkflows::Patches::Models::GroupPatch
|
||||
end
|
||||
@ -22,8 +22,15 @@
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module Models
|
||||
module IssuePatch
|
||||
|
||||
attr_accessor 'custom_workflow_messages'
|
||||
|
||||
def custom_workflow_messages
|
||||
@custom_workflow_messages ||= {}
|
||||
end
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
before_save :before_save_custom_workflows
|
||||
@ -52,7 +59,6 @@ module RedmineCustomWorkflows
|
||||
def validate_status
|
||||
return true unless @saved_attributes && @saved_attributes['status_id'] != status_id &&
|
||||
!new_statuses_allowed_to(User.current, new_record?).collect(&:id).include?(status_id)
|
||||
|
||||
status_was = IssueStatus.find_by_id(status_id_was)
|
||||
status_new = IssueStatus.find_by_id(status_id)
|
||||
|
||||
@ -77,7 +83,10 @@ module RedmineCustomWorkflows
|
||||
end
|
||||
|
||||
def before_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :issue, self, :before_destroy
|
||||
res = CustomWorkflow.run_custom_workflows(:issue, self, :before_destroy)
|
||||
if res === false
|
||||
throw :abort
|
||||
end
|
||||
end
|
||||
|
||||
def after_destroy_custom_workflows
|
||||
@ -86,11 +95,12 @@ module RedmineCustomWorkflows
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
RedmineExtensions::PatchManager.register_model_patch 'Issue', 'RedmineCustomWorkflows::Patches::IssuePatch'
|
||||
RedmineExtensions::PatchManager.register_model_patch 'Issue', 'RedmineCustomWorkflows::Patches::Models::IssuePatch'
|
||||
else
|
||||
Issue.prepend RedmineCustomWorkflows::Patches::IssuePatch
|
||||
Issue.prepend RedmineCustomWorkflows::Patches::Models::IssuePatch
|
||||
end
|
||||
@ -0,0 +1,100 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module Models
|
||||
module IssueRelationPatch
|
||||
|
||||
attr_accessor 'custom_workflow_messages'
|
||||
|
||||
def custom_workflow_messages
|
||||
@custom_workflow_messages ||= {}
|
||||
end
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
before_save :before_save_custom_workflows
|
||||
after_save :after_save_custom_workflows
|
||||
before_destroy :before_destroy_custom_workflows
|
||||
after_destroy :after_destroy_custom_workflows
|
||||
end
|
||||
|
||||
base.prepend InstanceMethods
|
||||
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
|
||||
################################################################################################################
|
||||
# Overriden methods
|
||||
|
||||
# Override IssueRelation.to_s to rescue NoMethodError during CustomWorkflow.validate_syntax due to
|
||||
# logging of temporarily instatiated IssueRelation with no related issues set.
|
||||
def to_s(issue=nil)
|
||||
super
|
||||
rescue NoMethodError => e
|
||||
if issue_from.present? || issue_to.present?
|
||||
raise e
|
||||
end
|
||||
end
|
||||
|
||||
################################################################################################################
|
||||
# New methods
|
||||
|
||||
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
|
||||
throw :abort if errors.any?
|
||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||
ensure
|
||||
@saved_attributes = nil
|
||||
end
|
||||
|
||||
def after_save_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :issue_relation, self, :after_save
|
||||
end
|
||||
|
||||
def before_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :issue_relation, self, :before_destroy
|
||||
end
|
||||
|
||||
def after_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :issue_relation, self, :after_destroy
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
RedmineExtensions::PatchManager.register_model_patch 'IssueRelation',
|
||||
'RedmineCustomWorkflows::Patches::Models::IssueRelationPatch'
|
||||
else
|
||||
IssueRelation.prepend RedmineCustomWorkflows::Patches::Models::IssueRelationPatch
|
||||
end
|
||||
61
lib/redmine_custom_workflows/patches/models/mailer_patch.rb
Normal file
61
lib/redmine_custom_workflows/patches/models/mailer_patch.rb
Normal file
@ -0,0 +1,61 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module Models
|
||||
module MailerPatch
|
||||
|
||||
def self.deliver_custom_email(headers={})
|
||||
user = headers.delete :user
|
||||
headers[:to] = user.mail if user
|
||||
text_body = headers.delete :text_body
|
||||
html_body = headers.delete :html_body
|
||||
template_name = headers.delete :template_name
|
||||
template_params = headers.delete(:template_params) || {}
|
||||
if text_body || html_body
|
||||
mail headers do |format|
|
||||
format.text { render text: text_body } if text_body
|
||||
format.html { render text: html_body } if html_body
|
||||
end
|
||||
elsif template_name
|
||||
template_params.each { |k,v| instance_variable_set("@#{k}", v) }
|
||||
mail headers do |format|
|
||||
format.text { render template_name }
|
||||
format.html { render template_name } unless Setting.plain_text_mail?
|
||||
end
|
||||
else
|
||||
raise StandardError.new('Not :text_body, :html_body or :template_name specified')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
RedmineExtensions::PatchManager.register_model_patch 'Mailer', 'RedmineCustomWorkflows::Patches::Models::MailerPatch'
|
||||
else
|
||||
Mailer.prepend RedmineCustomWorkflows::Patches::Models::MailerPatch
|
||||
end
|
||||
91
lib/redmine_custom_workflows/patches/models/project_patch.rb
Normal file
91
lib/redmine_custom_workflows/patches/models/project_patch.rb
Normal file
@ -0,0 +1,91 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module Models
|
||||
module ProjectPatch
|
||||
|
||||
attr_accessor 'custom_workflow_messages'
|
||||
|
||||
def custom_workflow_messages
|
||||
@custom_workflow_messages ||= {}
|
||||
end
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
has_and_belongs_to_many :custom_workflows
|
||||
safe_attributes :custom_workflow_ids, if:
|
||||
lambda { |project, user| project.new_record? || user.allowed_to?(:manage_project_workflow, project) }
|
||||
|
||||
before_save :before_save_custom_workflows
|
||||
after_save :after_save_custom_workflows
|
||||
before_destroy :before_destroy_custom_workflows
|
||||
after_destroy :after_destroy_custom_workflows
|
||||
|
||||
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)
|
||||
end
|
||||
|
||||
[:before_add, :before_remove, :after_add, :after_remove].each do |observable|
|
||||
send("#{observable}_for_attachments") << lambda { |event, project, attachment| Project.attachments_callback(event, project, attachment) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def before_save_custom_workflows
|
||||
@project = self
|
||||
@saved_attributes = attributes.dup
|
||||
CustomWorkflow.run_shared_code self
|
||||
CustomWorkflow.run_custom_workflows :project, self, :before_save
|
||||
throw :abort if errors.any?
|
||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||
ensure
|
||||
@saved_attributes = nil
|
||||
end
|
||||
|
||||
def after_save_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :project, self, :after_save
|
||||
end
|
||||
|
||||
def before_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :project, self, :before_destroy
|
||||
end
|
||||
|
||||
def after_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :project, self, :after_destroy
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
RedmineExtensions::PatchManager.register_model_patch 'Project', 'RedmineCustomWorkflows::Patches::Models::ProjectPatch'
|
||||
else
|
||||
Project.prepend RedmineCustomWorkflows::Patches::Models::ProjectPatch
|
||||
end
|
||||
@ -0,0 +1,77 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module Models
|
||||
module TimeEntryPatch
|
||||
|
||||
attr_accessor 'custom_workflow_messages'
|
||||
|
||||
def custom_workflow_messages
|
||||
@custom_workflow_messages ||= {}
|
||||
end
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
before_save :before_save_custom_workflows
|
||||
after_save :after_save_custom_workflows
|
||||
before_destroy :before_destroy_custom_workflows
|
||||
after_destroy :after_destroy_custom_workflows
|
||||
end
|
||||
end
|
||||
|
||||
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)
|
||||
throw :abort if errors.any?
|
||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||
ensure
|
||||
@saved_attributes = nil
|
||||
end
|
||||
|
||||
def after_save_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :time_entry, self, :after_save
|
||||
end
|
||||
|
||||
def before_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :time_entry, self, :before_destroy
|
||||
end
|
||||
|
||||
def after_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :time_entry, self, :after_destroy
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
RedmineExtensions::PatchManager.register_model_patch 'TimeEntry',
|
||||
'RedmineCustomWorkflows::Patches::Models::TimeEntryPatch'
|
||||
else
|
||||
TimeEntry.prepend RedmineCustomWorkflows::Patches::Models::TimeEntryPatch
|
||||
end
|
||||
76
lib/redmine_custom_workflows/patches/models/user_patch.rb
Normal file
76
lib/redmine_custom_workflows/patches/models/user_patch.rb
Normal file
@ -0,0 +1,76 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module Models
|
||||
module UserPatch
|
||||
|
||||
attr_accessor 'custom_workflow_messages'
|
||||
|
||||
def custom_workflow_messages
|
||||
@custom_workflow_messages ||= {}
|
||||
end
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
before_save :before_save_custom_workflows
|
||||
after_save :after_save_custom_workflows
|
||||
before_destroy :before_destroy_custom_workflows
|
||||
after_destroy :after_destroy_custom_workflows
|
||||
end
|
||||
end
|
||||
|
||||
def before_save_custom_workflows
|
||||
@user = self
|
||||
@saved_attributes = attributes.dup
|
||||
CustomWorkflow.run_shared_code self
|
||||
CustomWorkflow.run_custom_workflows :user, self, :before_save
|
||||
throw :abort if errors.any?
|
||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||
ensure
|
||||
@saved_attributes = nil
|
||||
end
|
||||
|
||||
def after_save_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :user, self, :after_save
|
||||
end
|
||||
|
||||
def before_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :user, self, :before_destroy
|
||||
end
|
||||
|
||||
def after_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :user, self, :after_destroy
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
RedmineExtensions::PatchManager.register_model_patch 'User', 'RedmineCustomWorkflows::Patches::Models::UserPatch'
|
||||
else
|
||||
User.prepend RedmineCustomWorkflows::Patches::Models::UserPatch
|
||||
end
|
||||
76
lib/redmine_custom_workflows/patches/models/version_patch.rb
Normal file
76
lib/redmine_custom_workflows/patches/models/version_patch.rb
Normal file
@ -0,0 +1,76 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module Models
|
||||
module VersionPatch
|
||||
|
||||
attr_accessor 'custom_workflow_messages'
|
||||
|
||||
def custom_workflow_messages
|
||||
@custom_workflow_messages ||= {}
|
||||
end
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
before_save :before_save_custom_workflows
|
||||
after_save :after_save_custom_workflows
|
||||
before_destroy :before_destroy_custom_workflows
|
||||
after_destroy :after_destroy_custom_workflows
|
||||
end
|
||||
end
|
||||
|
||||
def before_save_custom_workflows
|
||||
@version = self
|
||||
@saved_attributes = attributes.dup
|
||||
CustomWorkflow.run_shared_code self
|
||||
CustomWorkflow.run_custom_workflows :version, self, :before_save
|
||||
throw :abort if errors.any?
|
||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||
ensure
|
||||
@saved_attributes = nil
|
||||
end
|
||||
|
||||
def after_save_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :version, self, :after_save
|
||||
end
|
||||
|
||||
def before_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :version, self, :before_destroy
|
||||
end
|
||||
|
||||
def after_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :version, self, :after_destroy
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
RedmineExtensions::PatchManager.register_model_patch 'Version', 'RedmineCustomWorkflows::Patches::Models::VersionPatch'
|
||||
else
|
||||
Version.prepend RedmineCustomWorkflows::Patches::Models::VersionPatch
|
||||
end
|
||||
@ -0,0 +1,77 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module Models
|
||||
module WikiContentPatch
|
||||
|
||||
attr_accessor 'custom_workflow_messages'
|
||||
|
||||
def custom_workflow_messages
|
||||
@custom_workflow_messages ||= {}
|
||||
end
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
before_save :before_save_custom_workflows
|
||||
after_save :after_save_custom_workflows
|
||||
before_destroy :before_destroy_custom_workflows
|
||||
after_destroy :after_destroy_custom_workflows
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
throw :abort if errors.any?
|
||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||
ensure
|
||||
@saved_attributes = nil
|
||||
end
|
||||
|
||||
def after_save_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :wiki_content, self, :after_save
|
||||
end
|
||||
|
||||
def before_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :wiki_content, self, :before_destroy
|
||||
end
|
||||
|
||||
def after_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :wiki_content, self, :after_destroy
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
RedmineExtensions::PatchManager.register_model_patch 'WikiContent',
|
||||
'RedmineCustomWorkflows::Patches::Models::WikiContentPatch'
|
||||
else
|
||||
WikiContent.prepend RedmineCustomWorkflows::Patches::Models::WikiContentPatch
|
||||
end
|
||||
@ -22,8 +22,15 @@
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module Models
|
||||
module WikiPagePatch
|
||||
|
||||
attr_accessor 'custom_workflow_messages'
|
||||
|
||||
def custom_workflow_messages
|
||||
@custom_workflow_messages ||= {}
|
||||
end
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
def self.attachments_callback(event, page, attachment)
|
||||
@ -41,11 +48,13 @@ module RedmineCustomWorkflows
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
RedmineExtensions::PatchManager.register_model_patch 'WikiPage', 'RedmineCustomWorkflows::Patches::WikiPagePatch'
|
||||
RedmineExtensions::PatchManager.register_model_patch 'WikiPage',
|
||||
'RedmineCustomWorkflows::Patches::Models::WikiPagePatch'
|
||||
else
|
||||
WikiPage.prepend RedmineCustomWorkflows::Patches::WikiPagePatch
|
||||
WikiPage.prepend RedmineCustomWorkflows::Patches::Models::WikiPagePatch
|
||||
end
|
||||
@ -1,83 +0,0 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module ProjectPatch
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
has_and_belongs_to_many :custom_workflows
|
||||
safe_attributes :custom_workflow_ids, if:
|
||||
lambda { |project, user| project.new_record? || user.allowed_to?(:manage_project_workflow, project) }
|
||||
|
||||
before_save :before_save_custom_workflows
|
||||
after_save :after_save_custom_workflows
|
||||
before_destroy :before_destroy_custom_workflows
|
||||
after_destroy :after_destroy_custom_workflows
|
||||
|
||||
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)
|
||||
end
|
||||
|
||||
[:before_add, :before_remove, :after_add, :after_remove].each do |observable|
|
||||
send("#{observable}_for_attachments") << lambda { |event, project, attachment| Project.attachments_callback(event, project, attachment) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def before_save_custom_workflows
|
||||
@project = self
|
||||
@saved_attributes = attributes.dup
|
||||
CustomWorkflow.run_shared_code self
|
||||
CustomWorkflow.run_custom_workflows :project, self, :before_save
|
||||
throw :abort if errors.any?
|
||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||
ensure
|
||||
@saved_attributes = nil
|
||||
end
|
||||
|
||||
def after_save_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :project, self, :after_save
|
||||
end
|
||||
|
||||
def before_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :project, self, :before_destroy
|
||||
end
|
||||
|
||||
def after_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :project, self, :after_destroy
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
RedmineExtensions::PatchManager.register_model_patch 'Project', 'RedmineCustomWorkflows::Patches::ProjectPatch'
|
||||
else
|
||||
Project.prepend RedmineCustomWorkflows::Patches::ProjectPatch
|
||||
end
|
||||
@ -1,68 +0,0 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module TimeEntryPatch
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
before_save :before_save_custom_workflows
|
||||
after_save :after_save_custom_workflows
|
||||
before_destroy :before_destroy_custom_workflows
|
||||
after_destroy :after_destroy_custom_workflows
|
||||
end
|
||||
end
|
||||
|
||||
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)
|
||||
throw :abort if errors.any?
|
||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||
ensure
|
||||
@saved_attributes = nil
|
||||
end
|
||||
|
||||
def after_save_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :time_entry, self, :after_save
|
||||
end
|
||||
|
||||
def before_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :time_entry, self, :before_destroy
|
||||
end
|
||||
|
||||
def after_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :time_entry, self, :after_destroy
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
RedmineExtensions::PatchManager.register_model_patch 'TimeEntry', 'RedmineCustomWorkflows::Patches::TimeEntryPatch'
|
||||
else
|
||||
TimeEntry.prepend RedmineCustomWorkflows::Patches::TimeEntryPatch
|
||||
end
|
||||
@ -1,68 +0,0 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module UserPatch
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
before_save :before_save_custom_workflows
|
||||
after_save :after_save_custom_workflows
|
||||
before_destroy :before_destroy_custom_workflows
|
||||
after_destroy :after_destroy_custom_workflows
|
||||
end
|
||||
end
|
||||
|
||||
def before_save_custom_workflows
|
||||
@user = self
|
||||
@saved_attributes = attributes.dup
|
||||
CustomWorkflow.run_shared_code self
|
||||
CustomWorkflow.run_custom_workflows :user, self, :before_save
|
||||
throw :abort if errors.any?
|
||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||
ensure
|
||||
@saved_attributes = nil
|
||||
end
|
||||
|
||||
def after_save_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :user, self, :after_save
|
||||
end
|
||||
|
||||
def before_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :user, self, :before_destroy
|
||||
end
|
||||
|
||||
def after_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :user, self, :after_destroy
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
RedmineExtensions::PatchManager.register_model_patch 'User', 'RedmineCustomWorkflows::Patches::UserPatch'
|
||||
else
|
||||
User.prepend RedmineCustomWorkflows::Patches::UserPatch
|
||||
end
|
||||
@ -1,68 +0,0 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module VersionPatch
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
before_save :before_save_custom_workflows
|
||||
after_save :after_save_custom_workflows
|
||||
before_destroy :before_destroy_custom_workflows
|
||||
after_destroy :after_destroy_custom_workflows
|
||||
end
|
||||
end
|
||||
|
||||
def before_save_custom_workflows
|
||||
@version = self
|
||||
@saved_attributes = attributes.dup
|
||||
CustomWorkflow.run_shared_code self
|
||||
CustomWorkflow.run_custom_workflows :version, self, :before_save
|
||||
throw :abort if errors.any?
|
||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||
ensure
|
||||
@saved_attributes = nil
|
||||
end
|
||||
|
||||
def after_save_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :version, self, :after_save
|
||||
end
|
||||
|
||||
def before_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :version, self, :before_destroy
|
||||
end
|
||||
|
||||
def after_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :version, self, :after_destroy
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
RedmineExtensions::PatchManager.register_model_patch 'Version', 'RedmineCustomWorkflows::Patches::VersionPatch'
|
||||
else
|
||||
Version.prepend RedmineCustomWorkflows::Patches::VersionPatch
|
||||
end
|
||||
@ -1,68 +0,0 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Patches
|
||||
module WikiContentPatch
|
||||
|
||||
def self.prepended(base)
|
||||
base.class_eval do
|
||||
before_save :before_save_custom_workflows
|
||||
after_save :after_save_custom_workflows
|
||||
before_destroy :before_destroy_custom_workflows
|
||||
after_destroy :after_destroy_custom_workflows
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
throw :abort if errors.any?
|
||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||
ensure
|
||||
@saved_attributes = nil
|
||||
end
|
||||
|
||||
def after_save_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :wiki_content, self, :after_save
|
||||
end
|
||||
|
||||
def before_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :wiki_content, self, :before_destroy
|
||||
end
|
||||
|
||||
def after_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows :wiki_content, self, :after_destroy
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
if Redmine::Plugin.installed?(:easy_extensions)
|
||||
RedmineExtensions::PatchManager.register_model_patch 'WikiContent', 'RedmineCustomWorkflows::Patches::WikiContentPatch'
|
||||
else
|
||||
WikiContent.prepend RedmineCustomWorkflows::Patches::WikiContentPatch
|
||||
end
|
||||
176
test/fixtures/custom_workflows.yml
vendored
176
test/fixtures/custom_workflows.yml
vendored
@ -1,8 +1,8 @@
|
||||
---
|
||||
custom_workflows_001:
|
||||
id: 1
|
||||
before_save: "Rails.logger.info '>>> before save'"
|
||||
after_save: "Rails.logger.info '>>> after save'"
|
||||
before_save: "self.custom_workflow_messages[:notice] = 'Custom workflow'"
|
||||
after_save: ''
|
||||
name: 'Issue CW test'
|
||||
description: 'Testing workflow'
|
||||
position: 1
|
||||
@ -17,5 +17,173 @@ custom_workflows_001:
|
||||
after_add: NULL
|
||||
before_remove: NULL
|
||||
after_remove: NULL
|
||||
before_destroy: "Rails.logger.info '>>> before destroy'"
|
||||
after_destroy : "Rails.logger.info '>>> after destroy'"
|
||||
before_destroy: ''
|
||||
after_destroy : ''
|
||||
|
||||
custom_workflows_002:
|
||||
id: 2
|
||||
before_save: "self.custom_workflow_messages[:notice] = 'Custom workflow'"
|
||||
after_save: ''
|
||||
name: 'Version CW test'
|
||||
description: 'Testing workflow'
|
||||
position: 2
|
||||
is_for_all: 0
|
||||
author: 'karel.picman@kontron.com'
|
||||
created_at: 2018-12-20 14:01:27 +02:00
|
||||
updated_at: 2018-12-20 14:01:27 +02:00
|
||||
active: 1
|
||||
observable: 'version'
|
||||
shared_code: NULL
|
||||
before_add: NULL
|
||||
after_add: NULL
|
||||
before_remove: NULL
|
||||
after_remove: NULL
|
||||
before_destroy: ''
|
||||
after_destroy : ''
|
||||
|
||||
custom_workflows_003:
|
||||
id: 3
|
||||
before_save: "self.custom_workflow_messages[:notice] = 'Custom workflow'"
|
||||
after_save: ''
|
||||
name: 'User CW test'
|
||||
description: 'Testing workflow'
|
||||
position: 3
|
||||
is_for_all: 0
|
||||
author: 'karel.picman@kontron.com'
|
||||
created_at: 2018-12-20 14:01:27 +02:00
|
||||
updated_at: 2018-12-20 14:01:27 +02:00
|
||||
active: 1
|
||||
observable: 'user'
|
||||
shared_code: NULL
|
||||
before_add: NULL
|
||||
after_add: NULL
|
||||
before_remove: NULL
|
||||
after_remove: NULL
|
||||
before_destroy: ''
|
||||
after_destroy : ''
|
||||
|
||||
custom_workflows_004:
|
||||
id: 4
|
||||
before_save: "self.custom_workflow_messages[:notice] = 'Custom workflow'"
|
||||
after_save: ''
|
||||
name: 'Project CW test'
|
||||
description: 'Testing workflow'
|
||||
position: 4
|
||||
is_for_all: 0
|
||||
author: 'karel.picman@kontron.com'
|
||||
created_at: 2018-12-20 14:01:27 +02:00
|
||||
updated_at: 2018-12-20 14:01:27 +02:00
|
||||
active: 1
|
||||
observable: 'project'
|
||||
shared_code: NULL
|
||||
before_add: NULL
|
||||
after_add: NULL
|
||||
before_remove: NULL
|
||||
after_remove: NULL
|
||||
before_destroy: ''
|
||||
after_destroy : ''
|
||||
|
||||
custom_workflows_005:
|
||||
id: 5
|
||||
before_save: "self.custom_workflow_messages[:notice] = 'Custom workflow'"
|
||||
after_save: ''
|
||||
name: 'Group CW test'
|
||||
description: 'Testing workflow'
|
||||
position: 5
|
||||
is_for_all: 0
|
||||
author: 'karel.picman@kontron.com'
|
||||
created_at: 2018-12-20 14:01:27 +02:00
|
||||
updated_at: 2018-12-20 14:01:27 +02:00
|
||||
active: 1
|
||||
observable: 'group'
|
||||
shared_code: NULL
|
||||
before_add: NULL
|
||||
after_add: NULL
|
||||
before_remove: NULL
|
||||
after_remove: NULL
|
||||
before_destroy: ''
|
||||
after_destroy : ''
|
||||
|
||||
custom_workflows_006:
|
||||
id: 6
|
||||
before_save: ''
|
||||
after_save: ''
|
||||
name: 'Attachment CW test'
|
||||
description: 'Testing workflow'
|
||||
position: 6
|
||||
is_for_all: 0
|
||||
author: 'karel.picman@kontron.com'
|
||||
created_at: 2018-12-20 14:01:27 +02:00
|
||||
updated_at: 2018-12-20 14:01:27 +02:00
|
||||
active: 1
|
||||
observable: 'attachment'
|
||||
shared_code: NULL
|
||||
before_add: NULL
|
||||
after_add: NULL
|
||||
before_remove: NULL
|
||||
after_remove: NULL
|
||||
before_destroy: "self.custom_workflow_messages[:notice] = 'Custom workflow'"
|
||||
after_destroy : ''
|
||||
|
||||
custom_workflows_007:
|
||||
id: 7
|
||||
before_save: ''
|
||||
after_save: ''
|
||||
name: 'Issue relation CW test'
|
||||
description: 'Testing workflow'
|
||||
position: 7
|
||||
is_for_all: 0
|
||||
author: 'karel.picman@kontron.com'
|
||||
created_at: 2018-12-20 14:01:27 +02:00
|
||||
updated_at: 2018-12-20 14:01:27 +02:00
|
||||
active: 1
|
||||
observable: 'issue_relation'
|
||||
shared_code: NULL
|
||||
before_add: NULL
|
||||
after_add: NULL
|
||||
before_remove: NULL
|
||||
after_remove: NULL
|
||||
before_destroy: "self.custom_workflow_messages[:notice] = 'Custom workflow'"
|
||||
after_destroy : ''
|
||||
|
||||
custom_workflows_008:
|
||||
id: 8
|
||||
before_save: ''
|
||||
after_save: ''
|
||||
name: 'Time entry CW test'
|
||||
description: 'Testing workflow'
|
||||
position: 8
|
||||
is_for_all: 0
|
||||
author: 'karel.picman@kontron.com'
|
||||
created_at: 2018-12-20 14:01:27 +02:00
|
||||
updated_at: 2018-12-20 14:01:27 +02:00
|
||||
active: 1
|
||||
observable: 'time_entry'
|
||||
shared_code: NULL
|
||||
before_add: NULL
|
||||
after_add: NULL
|
||||
before_remove: NULL
|
||||
after_remove: NULL
|
||||
before_destroy: "self.custom_workflow_messages[:notice] = 'Custom workflow'"
|
||||
after_destroy : ''
|
||||
|
||||
custom_workflows_009:
|
||||
id: 9
|
||||
before_save: "self.custom_workflow_messages[:notice] = 'Custom workflow'"
|
||||
after_save: ''
|
||||
name: 'Wiki CW test'
|
||||
description: 'Testing workflow'
|
||||
position: 9
|
||||
is_for_all: 0
|
||||
author: 'karel.picman@kontron.com'
|
||||
created_at: 2018-12-20 14:01:27 +02:00
|
||||
updated_at: 2018-12-20 14:01:27 +02:00
|
||||
active: 1
|
||||
observable: 'wiki_content'
|
||||
shared_code: NULL
|
||||
before_add: NULL
|
||||
after_add: NULL
|
||||
before_remove: NULL
|
||||
after_remove: NULL
|
||||
before_destroy: ''
|
||||
after_destroy : ''
|
||||
18
test/fixtures/custom_workflows_projects.yml
vendored
18
test/fixtures/custom_workflows_projects.yml
vendored
@ -1,4 +1,20 @@
|
||||
---
|
||||
custom_workflows_projects_001:
|
||||
project_id: 1
|
||||
custom_workflow_id: 1
|
||||
custom_workflow_id: 1 # Issue
|
||||
|
||||
custom_workflows_projects_002:
|
||||
project_id: 1
|
||||
custom_workflow_id: 2 # Version
|
||||
|
||||
custom_workflows_projects_003:
|
||||
project_id: 1
|
||||
custom_workflow_id: 4 # Project
|
||||
|
||||
custom_workflows_projects_004:
|
||||
project_id: 1
|
||||
custom_workflow_id: 8 # Time entry
|
||||
|
||||
custom_workflows_projects_005:
|
||||
project_id: 1
|
||||
custom_workflow_id: 9 # Wiki content
|
||||
|
||||
42
test/functional/attachments_controller_patch_test.rb
Normal file
42
test/functional/attachments_controller_patch_test.rb
Normal file
@ -0,0 +1,42 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
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
|
||||
@request.session[:user_id] = @jsmith.id
|
||||
@controller = AttachmentsController.new
|
||||
end
|
||||
|
||||
def test_delete_with_cw
|
||||
delete :destroy, params: { id: @attachment8 }
|
||||
assert_response :redirect
|
||||
assert_equal 'Custom workflow', @controller.flash[:notice]
|
||||
end
|
||||
|
||||
end
|
||||
@ -24,23 +24,17 @@ require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class CustomWorkflowsControllerTest < RedmineCustomWorkflows::Test::TestCase
|
||||
|
||||
fixtures :users, :email_addresses, :custom_workflows, :custom_workflows_projects, :projects, :roles,
|
||||
:members, :member_roles
|
||||
fixtures :custom_workflows
|
||||
|
||||
def setup
|
||||
super
|
||||
@cw1 = CustomWorkflow.find 1
|
||||
@project1 = Project.find 1
|
||||
@admin = User.find 1
|
||||
@manager = User.find 2
|
||||
User.current = nil
|
||||
@request.session[:user_id] = @admin.id
|
||||
end
|
||||
|
||||
def test_truth
|
||||
assert_kind_of CustomWorkflow, @cw1
|
||||
assert_kind_of Project, @project1
|
||||
assert_kind_of User, @manager
|
||||
assert_kind_of User, @admin
|
||||
end
|
||||
|
||||
def test_index_admin
|
||||
@ -49,7 +43,7 @@ class CustomWorkflowsControllerTest < RedmineCustomWorkflows::Test::TestCase
|
||||
end
|
||||
|
||||
def test_index_non_admin
|
||||
@request.session[:user_id] = @manager.id
|
||||
@request.session[:user_id] = @jsmith.id
|
||||
get :index
|
||||
assert_response :forbidden
|
||||
end
|
||||
|
||||
44
test/functional/groups_controller_patch_test.rb
Normal file
44
test/functional/groups_controller_patch_test.rb
Normal file
@ -0,0 +1,44 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class GroupControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
fixtures :custom_workflows, :custom_workflows_projects
|
||||
|
||||
def setup
|
||||
super
|
||||
@group10 = Group.find 10
|
||||
@request.session[:user_id] = @admin.id
|
||||
@controller = GroupsController.new
|
||||
default_url_options[:host] = 'test.host'
|
||||
end
|
||||
|
||||
def test_update_with_cw
|
||||
@request.headers['Referer'] = edit_group_path(id: @group10.id)
|
||||
put :update, params: { id: @group10.id, group: { name: 'Updated name' } }
|
||||
assert_redirected_to edit_group_path(id: @group10.id)
|
||||
assert_equal 'Custom workflow', @controller.flash[:notice]
|
||||
end
|
||||
|
||||
end
|
||||
43
test/functional/issue_relations_controller_patch_test.rb
Normal file
43
test/functional/issue_relations_controller_patch_test.rb
Normal file
@ -0,0 +1,43 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
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
|
||||
|
||||
def setup
|
||||
super
|
||||
@ir1 = IssueRelation.find 1
|
||||
@request.session[:user_id] = @jsmith.id
|
||||
@controller = AttachmentsController.new
|
||||
end
|
||||
|
||||
def test_delete_with_cw
|
||||
delete :destroy, params: { id: @ir1 }
|
||||
assert_response :redirect
|
||||
assert_equal 'Custom workflow', @controller.flash[:notice]
|
||||
end
|
||||
|
||||
end
|
||||
43
test/functional/issues_controller_patch_test.rb
Normal file
43
test/functional/issues_controller_patch_test.rb
Normal file
@ -0,0 +1,43 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
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
|
||||
@request.session[:user_id] = @jsmith.id
|
||||
@controller = IssuesController.new
|
||||
end
|
||||
|
||||
def test_update_with_cw
|
||||
put :update, params: { id: @issue1.id, issue: { subject: 'Updated subject' } }
|
||||
assert_redirected_to action: 'show', id: @issue1.id
|
||||
assert_equal 'Custom workflow', @controller.flash[:notice]
|
||||
end
|
||||
|
||||
end
|
||||
41
test/functional/projects_controller_patch_test.rb
Normal file
41
test/functional/projects_controller_patch_test.rb
Normal file
@ -0,0 +1,41 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
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
|
||||
@request.session[:user_id] = @jsmith.id
|
||||
@controller = ProjectsController.new
|
||||
end
|
||||
|
||||
def test_update_with_cw
|
||||
post :update, params: { id: @project1.id, project: { name: 'Updated name' } }
|
||||
assert_redirected_to settings_project_path(@project1)
|
||||
assert_equal 'Custom workflow', @controller.flash[:notice]
|
||||
end
|
||||
|
||||
end
|
||||
43
test/functional/timelog_controller_patch_test.rb
Normal file
43
test/functional/timelog_controller_patch_test.rb
Normal file
@ -0,0 +1,43 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
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
|
||||
@request.session[:user_id] = @jsmith.id
|
||||
@controller = TimelogController.new
|
||||
end
|
||||
|
||||
def test_delete_with_cw
|
||||
delete :destroy, params: { id: @te1 }
|
||||
assert_response :redirect
|
||||
assert_equal 'Custom workflow', @controller.flash[:notice]
|
||||
end
|
||||
|
||||
end
|
||||
40
test/functional/users_controller_patch_test.rb
Normal file
40
test/functional/users_controller_patch_test.rb
Normal file
@ -0,0 +1,40 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class UsersControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||
|
||||
fixtures :custom_workflows, :custom_workflows_projects
|
||||
|
||||
def setup
|
||||
super
|
||||
@request.session[:user_id] = @admin.id
|
||||
@controller = UsersController.new
|
||||
end
|
||||
|
||||
def test_update_with_cw
|
||||
put :update, params: { id: @jsmith.id, user: { lastname: 'updated_lastname' }}
|
||||
assert_redirected_to edit_user_path(id: @jsmith.id)
|
||||
assert_equal 'Custom workflow', @controller.flash[:notice]
|
||||
end
|
||||
|
||||
end
|
||||
41
test/functional/versions_controller_patch_test.rb
Normal file
41
test/functional/versions_controller_patch_test.rb
Normal file
@ -0,0 +1,41 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class VersionsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||
|
||||
fixtures :versions, :custom_workflows, :custom_workflows_projects, :roles, :members, :member_roles
|
||||
|
||||
def setup
|
||||
super
|
||||
@version1 = Version.find 1
|
||||
@request.session[:user_id] = @jsmith.id
|
||||
@controller = VersionsController.new
|
||||
end
|
||||
|
||||
def test_update_with_cw
|
||||
put :update, params: { id: @version1.id, version: { name: 'Updated version' } }
|
||||
assert_redirected_to settings_project_path(id: @project1, tab: 'versions')
|
||||
assert_equal 'Custom workflow', @controller.flash[:notice]
|
||||
end
|
||||
|
||||
end
|
||||
44
test/functional/wiki_controller_patch_test.rb
Normal file
44
test/functional/wiki_controller_patch_test.rb
Normal file
@ -0,0 +1,44 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
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
|
||||
@request.session[:user_id] = @jsmith.id
|
||||
@controller = WikiController.new
|
||||
end
|
||||
|
||||
def test_update_with_cw
|
||||
put :update, params: { project_id: @project1.id, id: 'Another_page',
|
||||
content: { comments: 'my comments', text: 'edited', version: 1 } }
|
||||
assert_response :redirect
|
||||
assert_equal 'Custom workflow', @controller.flash[:notice]
|
||||
end
|
||||
|
||||
end
|
||||
@ -22,32 +22,35 @@
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Test
|
||||
|
||||
class TestCase < ActionController::TestCase
|
||||
|
||||
self.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)
|
||||
dir = File.join( File.dirname(__FILE__), '../../../test/fixtures')
|
||||
dir = File.join(File.dirname(__FILE__), 'fixtures')
|
||||
redmine_table_names = []
|
||||
table_names.each do |x|
|
||||
ActiveRecord::FixtureSet.create_fixtures(dir, x) if File.exist?("#{dir}/#{x}.yml")
|
||||
if File.exist?(File.join(dir, "#{x}.yml"))
|
||||
ActiveRecord::FixtureSet.create_fixtures(dir, x)
|
||||
else
|
||||
redmine_table_names << x
|
||||
end
|
||||
super(table_names)
|
||||
end
|
||||
super redmine_table_names if redmine_table_names.any?
|
||||
end
|
||||
|
||||
def setup
|
||||
if ::Rails::VERSION::MAJOR >= 5
|
||||
if ::Rails::VERSION::MINOR >= 1
|
||||
@request = ActionController::TestRequest.create(self.class.controller_class)
|
||||
else
|
||||
@request = ActionController::TestRequest.create
|
||||
end
|
||||
else
|
||||
@request = ActionController::TestRequest.new
|
||||
end
|
||||
@response = ActionController::TestResponse.new
|
||||
@jsmith = User.find_by(login: 'jsmith')
|
||||
@admin = User.find_by(login: 'admin')
|
||||
@project1 = Project.find 1
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@ -24,3 +24,4 @@
|
||||
require File.expand_path('../../../../test/test_helper', __FILE__)
|
||||
|
||||
require_relative 'unit_test'
|
||||
require_relative 'test_case'
|
||||
@ -20,20 +20,22 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module RedmineCustomWorkflows
|
||||
module Test
|
||||
class UnitTest < ActiveSupport::TestCase
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
# 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__), '../../../test/fixtures')
|
||||
table_names.each do |x|
|
||||
ActiveRecord::FixtureSet.create_fixtures(dir, x) if File.exist?("#{dir}/#{x}.yml")
|
||||
end
|
||||
super(table_names)
|
||||
class AttachmentPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||
fixtures :attachments
|
||||
|
||||
def setup
|
||||
@attachment1 = Attachment.find 1
|
||||
end
|
||||
|
||||
def test_truth
|
||||
assert_kind_of Attachment, @attachment1
|
||||
end
|
||||
|
||||
def test_custom_workflow_messages
|
||||
@attachment1.custom_workflow_messages[:notice] = 'Okay'
|
||||
assert_equal 'Okay', @attachment1.custom_workflow_messages[:notice]
|
||||
end
|
||||
|
||||
end
|
||||
@ -37,5 +37,42 @@ class CustomWorkflowTest < RedmineCustomWorkflows::Test::UnitTest
|
||||
assert_equal @cw1.name, @cw1.to_s
|
||||
end
|
||||
|
||||
def test_import_from_xml
|
||||
xml = %{
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<hash>
|
||||
<id type="integer">20</id>
|
||||
<before-save>Rails.logger.info '>>> Okay'</before-save>
|
||||
<after-save></after-save>
|
||||
<name>cw 1</name>
|
||||
<description>Desc.</description>
|
||||
<position type="integer">4</position>
|
||||
<is-for-all type="boolean">false</is-for-all>
|
||||
<author>karel.picman@kontron.com</author>
|
||||
<created-at type="dateTime">2022-09-21T12:14:21Z</created-at>
|
||||
<updated-at type="dateTime">2022-09-21T12:14:21Z</updated-at>
|
||||
<active type="boolean">true</active>
|
||||
<observable>issue</observable>
|
||||
<shared-code nil="true"/>
|
||||
<before-add nil="true"/>
|
||||
<after-add nil="true"/>
|
||||
<before-remove nil="true"/>
|
||||
<after-remove nil="true"/>
|
||||
<before-destroy></before-destroy>
|
||||
<after-destroy></after-destroy>
|
||||
<exported-at>2022-09-21T12:31:17Z</exported-at>
|
||||
<plugin-version>2.0.6 devel</plugin-version>
|
||||
<ruby-version>3.0.2-p107</ruby-version>
|
||||
<rails-version>6.1.6.1</rails-version>
|
||||
</hash>
|
||||
}
|
||||
cw = CustomWorkflow.import_from_xml(xml)
|
||||
assert cw
|
||||
end
|
||||
|
||||
def test_export_as_xml
|
||||
xml = @cw1.export_as_xml
|
||||
assert xml.include?("<name>#{@cw1}</name>")
|
||||
end
|
||||
|
||||
end
|
||||
41
test/unit/group_patch_test.rb
Normal file
41
test/unit/group_patch_test.rb
Normal file
@ -0,0 +1,41 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class GroupPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||
fixtures :users
|
||||
|
||||
def setup
|
||||
@group10 = Group.find 10
|
||||
end
|
||||
|
||||
def test_truth
|
||||
assert_kind_of Group, @group10
|
||||
end
|
||||
|
||||
def test_custom_workflow_messages
|
||||
@group10.custom_workflow_messages[:notice] = 'Okay'
|
||||
assert_equal 'Okay', @group10.custom_workflow_messages[:notice]
|
||||
end
|
||||
|
||||
end
|
||||
41
test/unit/issue_patch_test.rb
Normal file
41
test/unit/issue_patch_test.rb
Normal file
@ -0,0 +1,41 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class IssuePatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||
fixtures :issues
|
||||
|
||||
def setup
|
||||
@issue1 = Issue.find 1
|
||||
end
|
||||
|
||||
def test_truth
|
||||
assert_kind_of Issue, @issue1
|
||||
end
|
||||
|
||||
def test_custom_workflow_messages
|
||||
@issue1.custom_workflow_messages[:notice] = 'Okay'
|
||||
assert_equal 'Okay', @issue1.custom_workflow_messages[:notice]
|
||||
end
|
||||
|
||||
end
|
||||
41
test/unit/issue_relation_patch_test.rb
Normal file
41
test/unit/issue_relation_patch_test.rb
Normal file
@ -0,0 +1,41 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class IssueRelationPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||
fixtures :issue_relations
|
||||
|
||||
def setup
|
||||
@issue_relation1 = IssueRelation.find 1
|
||||
end
|
||||
|
||||
def test_truth
|
||||
assert_kind_of IssueRelation, @issue_relation1
|
||||
end
|
||||
|
||||
def test_custom_workflow_messages
|
||||
@issue_relation1.custom_workflow_messages[:notice] = 'Okay'
|
||||
assert_equal 'Okay', @issue_relation1.custom_workflow_messages[:notice]
|
||||
end
|
||||
|
||||
end
|
||||
41
test/unit/project_patch_test.rb
Normal file
41
test/unit/project_patch_test.rb
Normal file
@ -0,0 +1,41 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class ProjectPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||
fixtures :projects
|
||||
|
||||
def setup
|
||||
@project1 = Project.find 1
|
||||
end
|
||||
|
||||
def test_truth
|
||||
assert_kind_of Project, @project1
|
||||
end
|
||||
|
||||
def test_custom_workflow_messages
|
||||
@project1.custom_workflow_messages[:notice] = 'Okay'
|
||||
assert_equal 'Okay', @project1.custom_workflow_messages[:notice]
|
||||
end
|
||||
|
||||
end
|
||||
41
test/unit/time_entry_patch_test.rb
Normal file
41
test/unit/time_entry_patch_test.rb
Normal file
@ -0,0 +1,41 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class TimeEntryPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||
fixtures :time_entries
|
||||
|
||||
def setup
|
||||
@time_entry1 = TimeEntry.find 1
|
||||
end
|
||||
|
||||
def test_truth
|
||||
assert_kind_of TimeEntry, @time_entry1
|
||||
end
|
||||
|
||||
def test_custom_workflow_messages
|
||||
@time_entry1.custom_workflow_messages[:notice] = 'Okay'
|
||||
assert_equal 'Okay', @time_entry1.custom_workflow_messages[:notice]
|
||||
end
|
||||
|
||||
end
|
||||
41
test/unit/user_patch_test.rb
Normal file
41
test/unit/user_patch_test.rb
Normal file
@ -0,0 +1,41 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class UserPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||
fixtures :users
|
||||
|
||||
def setup
|
||||
@user1 = User.find 1
|
||||
end
|
||||
|
||||
def test_truth
|
||||
assert_kind_of User, @user1
|
||||
end
|
||||
|
||||
def test_custom_workflow_messages
|
||||
@user1.custom_workflow_messages[:notice] = 'Okay'
|
||||
assert_equal 'Okay', @user1.custom_workflow_messages[:notice]
|
||||
end
|
||||
|
||||
end
|
||||
41
test/unit/version_patch_test.rb
Normal file
41
test/unit/version_patch_test.rb
Normal file
@ -0,0 +1,41 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class VersionPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||
fixtures :versions
|
||||
|
||||
def setup
|
||||
@version1 = Version.find 1
|
||||
end
|
||||
|
||||
def test_truth
|
||||
assert_kind_of Version, @version1
|
||||
end
|
||||
|
||||
def test_custom_workflow_messages
|
||||
@version1.custom_workflow_messages[:notice] = 'Okay'
|
||||
assert_equal 'Okay', @version1.custom_workflow_messages[:notice]
|
||||
end
|
||||
|
||||
end
|
||||
41
test/unit/wiki_content_patch_test.rb
Normal file
41
test/unit/wiki_content_patch_test.rb
Normal file
@ -0,0 +1,41 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class WikiContentPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||
fixtures :wiki_contents
|
||||
|
||||
def setup
|
||||
@wiki_content1 = WikiContent.find 1
|
||||
end
|
||||
|
||||
def test_truth
|
||||
assert_kind_of WikiContent, @wiki_content1
|
||||
end
|
||||
|
||||
def test_custom_workflow_messages
|
||||
@wiki_content1.custom_workflow_messages[:notice] = 'Okay'
|
||||
assert_equal 'Okay', @wiki_content1.custom_workflow_messages[:notice]
|
||||
end
|
||||
|
||||
end
|
||||
41
test/unit/wiki_page_patch_test.rb
Normal file
41
test/unit/wiki_page_patch_test.rb
Normal file
@ -0,0 +1,41 @@
|
||||
# encoding: utf-8
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
# Redmine plugin for Custom Workflows
|
||||
#
|
||||
# Copyright © 2015-19 Anton Argirov
|
||||
# Copyright © 2019-22 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class WikiPagePatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||
fixtures :wiki_pages
|
||||
|
||||
def setup
|
||||
@wiki_page1 = WikiPage.find 1
|
||||
end
|
||||
|
||||
def test_truth
|
||||
assert_kind_of WikiPage, @wiki_page1
|
||||
end
|
||||
|
||||
def test_custom_workflow_messages
|
||||
@wiki_page1.custom_workflow_messages[:notice] = 'Okay'
|
||||
assert_equal 'Okay', @wiki_page1.custom_workflow_messages[:notice]
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user