mirror of
https://github.com/anteo/redmine_custom_workflows.git
synced 2026-01-26 08:14:20 +00:00
Rubocop tests
This commit is contained in:
parent
11164f452f
commit
042761b6e0
5
.github/workflows/rubyonrails.yml
vendored
5
.github/workflows/rubyonrails.yml
vendored
@ -122,6 +122,11 @@ jobs:
|
|||||||
cd /opt/redmine
|
cd /opt/redmine
|
||||||
bundle exec rake redmine:plugins:test:units
|
bundle exec rake redmine:plugins:test:units
|
||||||
bundle exec rake redmine:plugins:test:functionals
|
bundle exec rake redmine:plugins:test:functionals
|
||||||
|
- name: Rubocop
|
||||||
|
# Run the Rubocop tests
|
||||||
|
run: |
|
||||||
|
cd /opt/redmine
|
||||||
|
bundle exec rubocop -c plugins/redmine_custom_workflows/.rubocop.yml plugins/redmine_custom_workflows/
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
# Rollback plugin's changes to the database
|
# Rollback plugin's changes to the database
|
||||||
# Stop the database engine
|
# Stop the database engine
|
||||||
|
|||||||
60
.rubocop.yml
Normal file
60
.rubocop.yml
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
# Redmine plugin for Custom Workflows
|
||||||
|
#
|
||||||
|
# Copyright © 2015-19 Anton Argirov
|
||||||
|
# Copyright © 2019-23 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.
|
||||||
|
|
||||||
|
AllCops:
|
||||||
|
TargetRubyVersion: 2.7
|
||||||
|
TargetRailsVersion: 6.1
|
||||||
|
|
||||||
|
NewCops: enable
|
||||||
|
|
||||||
|
Exclude:
|
||||||
|
- '**/vendor/**/*'
|
||||||
|
|
||||||
|
# Enable extensions
|
||||||
|
require:
|
||||||
|
- rubocop-performance
|
||||||
|
- rubocop-rails
|
||||||
|
|
||||||
|
# Rules for CustomWorkflows
|
||||||
|
Layout/EmptyLineAfterMagicComment:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
|
Metrics/BlockLength:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
|
Metrics/ClassLength:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
|
Metrics/MethodLength:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
|
Metrics/AbcSize:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
|
Metrics/PerceivedComplexity:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
|
Metrics/CyclomaticComplexity:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
|
Rails/HasAndBelongsToMany:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
|
Style/ExpandPathArguments:
|
||||||
|
Enabled: false
|
||||||
2
Gemfile
2
Gemfile
@ -1,4 +1,4 @@
|
|||||||
# encoding: utf-8
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -21,17 +20,17 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require 'redmine'
|
require 'redmine'
|
||||||
require File.dirname(__FILE__) + '/lib/redmine_custom_workflows'
|
require "#{File.dirname(__FILE__)}/lib/redmine_custom_workflows"
|
||||||
|
|
||||||
def custom_workflows_init
|
def custom_workflows_init
|
||||||
# Administration menu extension
|
# Administration menu extension
|
||||||
Redmine::MenuManager.map :admin_menu do |menu|
|
Redmine::MenuManager.map :admin_menu do |menu|
|
||||||
menu.push :custom_workflows, { controller: 'custom_workflows', action: 'index'},
|
menu.push :custom_workflows, { controller: 'custom_workflows', action: 'index' },
|
||||||
caption: :label_custom_workflow_plural, html: { class: 'icon icon-workflows workflows'}
|
caption: :label_custom_workflow_plural, html: { class: 'icon icon-workflows workflows' }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if Redmine::Plugin.installed?(:easy_extensions)
|
if Redmine::Plugin.installed?('easy_extensions')
|
||||||
ActiveSupport.on_load(:easyproject, yield: true) do
|
ActiveSupport.on_load(:easyproject, yield: true) do
|
||||||
custom_workflows_init
|
custom_workflows_init
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -19,12 +18,12 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#
|
|
||||||
class CustomWorkflowsController < ApplicationController
|
|
||||||
|
|
||||||
|
# Custom workflows controller
|
||||||
|
class CustomWorkflowsController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
before_action :require_admin
|
before_action :require_admin
|
||||||
before_action :find_workflow, only: [:show, :edit, :update, :destroy, :export, :change_status, :reorder]
|
before_action :find_workflow, only: %i[show edit update destroy export change_status reorder]
|
||||||
|
|
||||||
def reorder
|
def reorder
|
||||||
from = @workflow.position
|
from = @workflow.position
|
||||||
@ -32,21 +31,20 @@ class CustomWorkflowsController < ApplicationController
|
|||||||
CustomWorkflow.transaction do
|
CustomWorkflow.transaction do
|
||||||
CustomWorkflow.find_each do |wf|
|
CustomWorkflow.find_each do |wf|
|
||||||
if wf.position == from
|
if wf.position == from
|
||||||
wf.update_attribute :position, to
|
wf.position = to
|
||||||
elsif wf.position >= to && wf.position < from
|
elsif wf.position >= to && wf.position < from
|
||||||
# Move up
|
# Move up
|
||||||
wf.update_attribute :position, wf.position + 1
|
wf.position = wf.position + 1
|
||||||
elsif wf.position <= to && wf.position > from
|
elsif wf.position <= to && wf.position > from
|
||||||
# Move down
|
# Move down
|
||||||
wf.update_attribute :position, wf.position - 1
|
wf.position = wf.position - 1
|
||||||
end
|
end
|
||||||
|
wf.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.js {
|
format.js
|
||||||
render inline: "location.replace('#{custom_workflows_path}');"
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -67,8 +65,7 @@ class CustomWorkflowsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit; end
|
||||||
end
|
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@workflow = CustomWorkflow.new
|
@workflow = CustomWorkflow.new
|
||||||
@ -88,8 +85,8 @@ class CustomWorkflowsController < ApplicationController
|
|||||||
else
|
else
|
||||||
flash[:error] = @workflow.errors.full_messages.to_sentence
|
flash[:error] = @workflow.errors.full_messages.to_sentence
|
||||||
end
|
end
|
||||||
rescue Exception => e
|
rescue StandardError => e
|
||||||
Rails.logger.warn "Workflow import error: #{e.message}\n #{e.backtrace.join("\n ")}"
|
Rails.logger.warn { "Workflow import error: #{e.message}\n #{e.backtrace.join("\n ")}" }
|
||||||
flash[:error] = l(:error_failed_import)
|
flash[:error] = l(:error_failed_import)
|
||||||
end
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
@ -103,7 +100,7 @@ class CustomWorkflowsController < ApplicationController
|
|||||||
@workflow.observable = params[:custom_workflow][:observable]
|
@workflow.observable = params[:custom_workflow][:observable]
|
||||||
update_from_params
|
update_from_params
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if params.has_key?(:commit) && @workflow.save
|
if params.key?(:commit) && @workflow.save
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
cookies[:custom_workflows_author] = @workflow.author
|
cookies[:custom_workflows_author] = @workflow.author
|
||||||
format.html { redirect_to(custom_workflows_path) }
|
format.html { redirect_to(custom_workflows_path) }
|
||||||
@ -127,7 +124,7 @@ class CustomWorkflowsController < ApplicationController
|
|||||||
def update
|
def update
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
update_from_params
|
update_from_params
|
||||||
if params.has_key?(:commit) && @workflow.save
|
if params.key?(:commit) && @workflow.save
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
format.html { redirect_to(custom_workflows_path) }
|
format.html { redirect_to(custom_workflows_path) }
|
||||||
else
|
else
|
||||||
@ -169,5 +166,4 @@ class CustomWorkflowsController < ApplicationController
|
|||||||
@workflow.after_destroy = params[:custom_workflow][:after_destroy]
|
@workflow.after_destroy = params[:custom_workflow][:after_destroy]
|
||||||
@workflow.project_ids = params[:custom_workflow][:project_ids]
|
@workflow.project_ids = params[:custom_workflow][:project_ids]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
25
app/models/application_record.rb
Normal file
25
app/models/application_record.rb
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
#
|
||||||
|
# Redmine plugin for Custom Workflows
|
||||||
|
#
|
||||||
|
# Copyright © 2015-19 Anton Argirov
|
||||||
|
# Copyright © 2019-23 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.
|
||||||
|
|
||||||
|
# Application record class
|
||||||
|
class ApplicationRecord < ActiveRecord::Base
|
||||||
|
self.abstract_class = true
|
||||||
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -20,29 +19,37 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class CustomWorkflow < ActiveRecord::Base
|
# Custom workflow model
|
||||||
OBSERVABLES = [:issue, :issue_relation, :issue_attachments, :user, :attachment, :group, :group_users, :project, :project_attachments,
|
class CustomWorkflow < ApplicationRecord
|
||||||
:wiki_content, :wiki_page_attachments, :time_entry, :version, :shared]
|
OBSERVABLES = %i[issue issue_relation issue_attachments user attachment group group_users project project_attachments
|
||||||
PROJECT_OBSERVABLES = [:issue, :issue_attachments, :project, :project_attachments, :wiki_content, :wiki_page_attachments, :time_entry, :version]
|
wiki_content wiki_page_attachments time_entry version shared].freeze
|
||||||
COLLECTION_OBSERVABLES = [:group_users, :issue_attachments, :project_attachments, :wiki_page_attachments]
|
PROJECT_OBSERVABLES = %i[issue issue_attachments project project_attachments wiki_content wiki_page_attachments
|
||||||
SINGLE_OBSERVABLES = [:issue, :issue_relation, :user, :group, :attachment, :project, :wiki_content, :time_entry, :version]
|
time_entry version].freeze
|
||||||
|
COLLECTION_OBSERVABLES = %i[group_users issue_attachments project_attachments wiki_page_attachments].freeze
|
||||||
|
SINGLE_OBSERVABLES = %i[issue issue_relation user group attachment project wiki_content time_entry version].freeze
|
||||||
|
|
||||||
has_and_belongs_to_many :projects
|
|
||||||
acts_as_list
|
acts_as_list
|
||||||
|
|
||||||
validates_presence_of :name
|
has_and_belongs_to_many :projects
|
||||||
validates_uniqueness_of :name, case_sensitive: false
|
|
||||||
validates_format_of :author, with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, allow_blank: true
|
|
||||||
validate :validate_syntax, :validate_scripts_presence, if: Proc.new { |workflow| workflow.respond_to?(:observable) and workflow.active? }
|
|
||||||
|
|
||||||
scope :active, lambda { where(active: true) }
|
validates :name, uniqueness: true
|
||||||
scope :sorted, lambda { order(:position) }
|
validates :author, format: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, allow_blank: true
|
||||||
|
validate :validate_syntax, :validate_scripts_presence,
|
||||||
|
if: proc { |workflow| workflow.respond_to?(:observable) and workflow.active? }
|
||||||
|
|
||||||
|
scope :active, -> { where(active: true) }
|
||||||
|
scope :sorted, -> { order(:position) }
|
||||||
scope :for_project, (lambda do |project|
|
scope :for_project, (lambda do |project|
|
||||||
where("is_for_all=? OR EXISTS (SELECT * FROM #{reflect_on_association(:projects).join_table} WHERE project_id=? AND custom_workflow_id=id)",
|
where(
|
||||||
true, project.id)
|
%{
|
||||||
end)
|
is_for_all = ? OR
|
||||||
#scope :for_project, (lambda { |project| where(is_for_all: true).or(where(
|
EXISTS (SELECT * FROM #{reflect_on_association(:projects).join_table}
|
||||||
# 'SELECT * FROM custom_workflow_projects WHERE project_id = ? AND custom_workflow_id = id', project.id).exists?) })
|
WHERE project_id = ? AND custom_workflow_id = id)
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
project.id
|
||||||
|
)
|
||||||
|
end)
|
||||||
|
|
||||||
def self.import_from_xml(xml)
|
def self.import_from_xml(xml)
|
||||||
attributes = Hash.from_xml(xml).values.first
|
attributes = Hash.from_xml(xml).values.first
|
||||||
@ -76,9 +83,11 @@ class CustomWorkflow < ActiveRecord::Base
|
|||||||
workflows = CustomWorkflow.active.where(observable: observable)
|
workflows = CustomWorkflow.active.where(observable: observable)
|
||||||
if PROJECT_OBSERVABLES.include? observable
|
if PROJECT_OBSERVABLES.include? observable
|
||||||
return true unless object.project
|
return true unless object.project
|
||||||
|
|
||||||
workflows = workflows.for_project(object.project)
|
workflows = workflows.for_project(object.project)
|
||||||
end
|
end
|
||||||
return true unless workflows.any?
|
return true unless workflows.any?
|
||||||
|
|
||||||
log_message "= Running #{event} custom workflows", object
|
log_message "= Running #{event} custom workflows", object
|
||||||
workflows.sorted.each do |workflow|
|
workflows.sorted.each do |workflow|
|
||||||
unless workflow.run(object, event)
|
unless workflow.run(object, event)
|
||||||
@ -93,83 +102,83 @@ class CustomWorkflow < ActiveRecord::Base
|
|||||||
|
|
||||||
def run(object, event)
|
def run(object, event)
|
||||||
return true unless attribute_present?(event)
|
return true unless attribute_present?(event)
|
||||||
Rails.logger.info "== Running #{event} custom workflow \"#{name}\""
|
|
||||||
object.instance_eval(read_attribute(event))
|
Rails.logger.info { "== Running #{event} custom workflow \"#{name}\"" }
|
||||||
|
object.instance_eval self[event]
|
||||||
true
|
true
|
||||||
rescue RedmineCustomWorkflows::Errors::WorkflowError => e
|
rescue RedmineCustomWorkflows::Errors::WorkflowError => e
|
||||||
Rails.logger.info "== User workflow error: #{e.message}"
|
Rails.logger.info { "== User workflow error: #{e.message}" }
|
||||||
object.errors.add :base, e.message
|
object.errors.add :base, e.message
|
||||||
false
|
false
|
||||||
rescue Exception => e
|
rescue StandardError => e
|
||||||
Rails.logger.error "== Custom workflow #{name}, ##{id} exception: #{e.message}\n #{e.backtrace.join("\n ")}"
|
Rails.logger.error { "== Custom workflow #{name}, ##{id} exception: #{e.message}\n #{e.backtrace.join("\n ")}" }
|
||||||
object.errors.add :base, :custom_workflow_error
|
object.errors.add :base, :custom_workflow_error
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_projects_association?
|
def projects_association?
|
||||||
PROJECT_OBSERVABLES.include? observable.to_sym
|
PROJECT_OBSERVABLES.include? observable.to_sym
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_syntax_for(object, event)
|
def validate_syntax_for(object, event)
|
||||||
object.instance_eval(read_attribute(event)) if respond_to?(event) && read_attribute(event)
|
object.instance_eval(self[event]) if respond_to?(event) && self[event]
|
||||||
rescue RedmineCustomWorkflows::Errors::WorkflowError => _
|
rescue RedmineCustomWorkflows::Errors::WorkflowError => _e
|
||||||
rescue Exception => e
|
# Do nothing
|
||||||
|
rescue StandardError => e
|
||||||
errors.add event, :invalid_script, error: e
|
errors.add event, :invalid_script, error: e
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_scripts_presence
|
def validate_scripts_presence
|
||||||
case observable.to_sym
|
fields = case observable.to_sym
|
||||||
when :shared
|
when :shared
|
||||||
fields = [shared_code]
|
[shared_code]
|
||||||
when *SINGLE_OBSERVABLES
|
when *SINGLE_OBSERVABLES
|
||||||
fields = [before_save, after_save, before_destroy, after_destroy]
|
[before_save, after_save, before_destroy, after_destroy]
|
||||||
when *COLLECTION_OBSERVABLES
|
when *COLLECTION_OBSERVABLES
|
||||||
fields = [before_add, after_add, before_remove, after_remove]
|
[before_add, after_add, before_remove, after_remove]
|
||||||
else
|
else
|
||||||
fields = []
|
[]
|
||||||
end
|
end
|
||||||
unless fields.any? {|field| field.present?}
|
errors.add(:base, :scripts_absent) unless fields.any?(&:present?)
|
||||||
errors.add :base, :scripts_absent
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_syntax
|
def validate_syntax
|
||||||
case observable.to_sym
|
case observable.to_sym
|
||||||
when :shared
|
when :shared
|
||||||
CustomWorkflow.run_shared_code self
|
CustomWorkflow.run_shared_code self
|
||||||
validate_syntax_for self, :shared_code
|
validate_syntax_for self, :shared_code
|
||||||
when *SINGLE_OBSERVABLES
|
when *SINGLE_OBSERVABLES
|
||||||
object = observable.camelize.constantize.new
|
object = observable.camelize.constantize.new
|
||||||
object.send :instance_variable_set, "@#{observable}", object # compatibility with 0.0.1
|
object.send :instance_variable_set, "@#{observable}", object # compatibility with 0.0.1
|
||||||
CustomWorkflow.run_shared_code object
|
CustomWorkflow.run_shared_code object
|
||||||
[:before_save, :after_save, :before_destroy, :after_destroy].each {|field| validate_syntax_for object, field}
|
%i[before_save after_save before_destroy after_destroy].each { |field| validate_syntax_for object, field }
|
||||||
when *COLLECTION_OBSERVABLES
|
when *COLLECTION_OBSERVABLES
|
||||||
object = nil
|
object = nil
|
||||||
case observable.to_sym
|
case observable.to_sym
|
||||||
when :group_users
|
when :group_users
|
||||||
object = Group.new
|
object = Group.new
|
||||||
object.send :instance_variable_set, :@user, User.new
|
object.send :instance_variable_set, :@user, User.new
|
||||||
object.send :instance_variable_set, :@group, object
|
object.send :instance_variable_set, :@group, object
|
||||||
when :issue_attachments
|
when :issue_attachments
|
||||||
object = Issue.new
|
object = Issue.new
|
||||||
object.send :instance_variable_set, :@attachment, Attachment.new
|
object.send :instance_variable_set, :@attachment, Attachment.new
|
||||||
object.send :instance_variable_set, :@issue, object
|
object.send :instance_variable_set, :@issue, object
|
||||||
when :project_attachments
|
when :project_attachments
|
||||||
object = Project.new
|
object = Project.new
|
||||||
object.send :instance_variable_set, :@attachment, Attachment.new
|
object.send :instance_variable_set, :@attachment, Attachment.new
|
||||||
object.send :instance_variable_set, :@project, object
|
object.send :instance_variable_set, :@project, object
|
||||||
when :wiki_page_attachments
|
when :wiki_page_attachments
|
||||||
object = WikiPage.new
|
object = WikiPage.new
|
||||||
object.send :instance_variable_set, :@attachment, Attachment.new
|
object.send :instance_variable_set, :@attachment, Attachment.new
|
||||||
object.send :instance_variable_set, :@page, object
|
object.send :instance_variable_set, :@page, object
|
||||||
end
|
end
|
||||||
CustomWorkflow.run_shared_code object
|
CustomWorkflow.run_shared_code object
|
||||||
[:before_add, :after_add, :before_remove, :after_remove].each { |field| validate_syntax_for object, field }
|
%i[before_add after_add before_remove after_remove].each { |field| validate_syntax_for object, field }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def export_as_xml
|
def export_as_xml
|
||||||
attrs = self.attributes.dup
|
attrs = attributes.dup
|
||||||
attrs['exported-at'] = Time.current.xmlschema
|
attrs['exported-at'] = Time.current.xmlschema
|
||||||
attrs['plugin-version'] = Redmine::Plugin.find(:redmine_custom_workflows).version
|
attrs['plugin-version'] = Redmine::Plugin.find(:redmine_custom_workflows).version
|
||||||
attrs['ruby-version'] = "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
|
attrs['ruby-version'] = "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
|
||||||
@ -178,11 +187,10 @@ class CustomWorkflow < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def <=>(other)
|
def <=>(other)
|
||||||
self.position <=> other.position
|
position <=> other.position
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
name
|
name
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -22,6 +21,7 @@
|
|||||||
|
|
||||||
require 'mailer'
|
require 'mailer'
|
||||||
|
|
||||||
|
# Custom workflow mailer model
|
||||||
class CustomWorkflowMailer < Mailer
|
class CustomWorkflowMailer < Mailer
|
||||||
layout 'mailer'
|
layout 'mailer'
|
||||||
|
|
||||||
@ -34,5 +34,4 @@ class CustomWorkflowMailer < Mailer
|
|||||||
@text = text
|
@text = text
|
||||||
mail to: user, subject: subject
|
mail to: user, subject: subject
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,24 +1,22 @@
|
|||||||
<%
|
<%
|
||||||
# encoding: utf-8
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Copyright © 2015-19 Anton Argirov
|
||||||
#
|
# Copyright © 2019-23 Karel Pičman <karel.picman@kontron.com>
|
||||||
# Copyright © 2015-19 Anton Argirov
|
#
|
||||||
# Copyright © 2019-23 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
|
||||||
# This program is free software; you can redistribute it and/or
|
# as published by the Free Software Foundation; either version 2
|
||||||
# modify it under the terms of the GNU General Public License
|
# of the License, or (at your option) any later version.
|
||||||
# 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
|
||||||
# This program is distributed in the hope that it will be useful,
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# GNU General Public License for more details.
|
||||||
# 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
|
||||||
# You should have received a copy of the GNU General Public License
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
<%
|
<%
|
||||||
# encoding: utf-8
|
|
||||||
#
|
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
# Copyright © 2015-19 Anton Argirov
|
# Copyright © 2015-19 Anton Argirov
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
<%
|
<%
|
||||||
# encoding: utf-8
|
|
||||||
#
|
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
# Copyright © 2015-19 Anton Argirov
|
# Copyright © 2015-19 Anton Argirov
|
||||||
@ -33,7 +31,7 @@
|
|||||||
onchange: 'this.form.submit()',
|
onchange: 'this.form.submit()',
|
||||||
disabled: !@workflow.new_record? %></p>
|
disabled: !@workflow.new_record? %></p>
|
||||||
<p><%= f.text_area :description, class: 'wiki-edit' %></p>
|
<p><%= f.text_area :description, class: 'wiki-edit' %></p>
|
||||||
<% if @workflow.has_projects_association? %>
|
<% if @workflow.projects_association? %>
|
||||||
<p>
|
<p>
|
||||||
<%= f.check_box :is_for_all, onclick: "checkAndDisable('custom_workflow_enabled_projects', this.checked);",
|
<%= f.check_box :is_for_all, onclick: "checkAndDisable('custom_workflow_enabled_projects', this.checked);",
|
||||||
label: :field_enabled_for_all_projects %>
|
label: :field_enabled_for_all_projects %>
|
||||||
@ -42,7 +40,7 @@
|
|||||||
<p><%= f.check_box :active, label: l(:field_active) %></p>
|
<p><%= f.check_box :active, label: l(:field_active) %></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% if @workflow.has_projects_association? %>
|
<% if @workflow.projects_association? %>
|
||||||
<div class="splitcontentright">
|
<div class="splitcontentright">
|
||||||
<div class="box tabular">
|
<div class="box tabular">
|
||||||
<%= content_tag 'fieldset', id: 'custom_workflow_enabled_projects' do %>
|
<%= content_tag 'fieldset', id: 'custom_workflow_enabled_projects' do %>
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
<%
|
<%
|
||||||
# encoding: utf-8
|
|
||||||
#
|
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
# Copyright © 2015-19 Anton Argirov
|
# Copyright © 2015-19 Anton Argirov
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
<%
|
<%
|
||||||
# encoding: utf-8
|
|
||||||
#
|
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
# Copyright © 2015-19 Anton Argirov
|
# Copyright © 2015-19 Anton Argirov
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
<%
|
<%
|
||||||
# encoding: utf-8
|
|
||||||
#
|
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
# Copyright © 2015-19 Anton Argirov
|
# Copyright © 2015-19 Anton Argirov
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
<%
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -18,12 +19,6 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
%>
|
||||||
|
|
||||||
class AddAuthorAndTimestampsToCustomWorkflows < ActiveRecord::Migration[4.2]
|
location.replace('<%= custom_workflows_path %>');
|
||||||
|
|
||||||
def change
|
|
||||||
add_column :custom_workflows, :author, :string, null: true
|
|
||||||
add_timestamps :custom_workflows
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
@ -1,6 +1,4 @@
|
|||||||
<%
|
<%
|
||||||
# encoding: utf-8
|
|
||||||
#
|
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
# Copyright © 2015-19 Anton Argirov
|
# Copyright © 2015-19 Anton Argirov
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -21,17 +20,14 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
RedmineApp::Application.routes.draw do
|
RedmineApp::Application.routes.draw do
|
||||||
|
|
||||||
resources :custom_workflows do
|
resources :custom_workflows do
|
||||||
member do
|
member do
|
||||||
|
# Nothing
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
post '/custom_workflows/import', to: 'custom_workflows#import', as: 'import_custom_workflow'
|
post '/custom_workflows/import', to: 'custom_workflows#import', as: 'import_custom_workflow'
|
||||||
post '/custom_workflows/:id', to: 'custom_workflows#update'
|
post '/custom_workflows/:id', to: 'custom_workflows#update'
|
||||||
get '/custom_workflows/:id/export', to: 'custom_workflows#export', as: 'export_custom_workflow'
|
get '/custom_workflows/:id/export', to: 'custom_workflows#export', as: 'export_custom_workflow'
|
||||||
post '/custom_workflows/:id/change_status', to: 'custom_workflows#change_status', as: 'custom_workflow_status'
|
post '/custom_workflows/:id/change_status', to: 'custom_workflows#change_status', as: 'custom_workflow_status'
|
||||||
put '/custom_workflows/:id/reorder', to: 'custom_workflows#reorder'
|
put '/custom_workflows/:id/reorder', to: 'custom_workflows#reorder'
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# encoding: utf-8
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
@ -19,15 +19,15 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
# Create the model table
|
||||||
class CreateCustomWorkflows < ActiveRecord::Migration[4.2]
|
class CreateCustomWorkflows < ActiveRecord::Migration[4.2]
|
||||||
|
|
||||||
def change
|
def change
|
||||||
create_table :custom_workflows, force: true do |t|
|
create_table :custom_workflows, force: true do |t|
|
||||||
t.references :project
|
t.references :project
|
||||||
t.text :script, null: true, default: nil
|
t.text :script, null: true, default: nil
|
||||||
t.boolean :is_enabled
|
t.boolean :is_enabled
|
||||||
|
t.timestamps
|
||||||
|
t.index :project_id, unique: true
|
||||||
end
|
end
|
||||||
add_index :custom_workflows, [:project_id], unique: true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# encoding: utf-8
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
@ -19,14 +19,25 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
# Modify the table
|
||||||
class AlterCustomWorkflows < ActiveRecord::Migration[4.2]
|
class AlterCustomWorkflows < ActiveRecord::Migration[4.2]
|
||||||
|
def up
|
||||||
def self.up
|
change_table(:custom_workflows, bulk: true) do |t|
|
||||||
remove_column :custom_workflows, :project_id
|
t.remove :project_id
|
||||||
remove_column :custom_workflows, :is_enabled
|
t.remove :is_enabled
|
||||||
add_column :custom_workflows, :name, :string, null: false, default: ''
|
t.string :name, null: false, default: ''
|
||||||
add_column :custom_workflows, :description, :string, null: false, default: ''
|
t.string :description, :string, null: false, default: ''
|
||||||
add_column :custom_workflows, :position, :integer, null: false, default: 1
|
t.integer :position, :integer, null: false, default: 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
change_table(:custom_workflows, bulk: true) do |t|
|
||||||
|
t.references :project
|
||||||
|
t.boolean :is_enabled
|
||||||
|
t.remove :name
|
||||||
|
t.remove :description
|
||||||
|
t.remove :position
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# encoding: utf-8
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
@ -19,15 +19,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
# Add table custom_workflows_projects
|
||||||
class CreateCustomWorkflowsProjects < ActiveRecord::Migration[4.2]
|
class CreateCustomWorkflowsProjects < ActiveRecord::Migration[4.2]
|
||||||
|
|
||||||
def change
|
def change
|
||||||
create_table :custom_workflows_projects, force: true, id: false do |t|
|
create_join_table :projects, :custom_workflows
|
||||||
t.references :project
|
|
||||||
t.references :custom_workflow
|
|
||||||
end
|
|
||||||
add_index :custom_workflows_projects, [:project_id]
|
|
||||||
add_index :custom_workflows_projects, [:custom_workflow_id]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# encoding: utf-8
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
@ -19,9 +19,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
# Modify column
|
||||||
class ChangeCustomWorkflowsDescriptionType < ActiveRecord::Migration[4.2]
|
class ChangeCustomWorkflowsDescriptionType < ActiveRecord::Migration[4.2]
|
||||||
def self.up
|
def up
|
||||||
change_column :custom_workflows, :description, :text, null: true, default: nil
|
change_column :custom_workflows, :description, :text, null: true, default: nil
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# encoding: utf-8
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
@ -19,17 +19,19 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
# Modify columns
|
||||||
class AddAfterSaveToCustomWorkflows < ActiveRecord::Migration[4.2]
|
class AddAfterSaveToCustomWorkflows < ActiveRecord::Migration[4.2]
|
||||||
|
|
||||||
def up
|
def up
|
||||||
rename_column :custom_workflows, :script, :before_save
|
change_table(:custom_workflows, bulk: true) do |t|
|
||||||
change_column :custom_workflows, :before_save, :text, null: true
|
t.rename :script, :before_save
|
||||||
add_column :custom_workflows, :after_save, :text, null: true, after: :before_save
|
t.text :after_save, null: true, after: :before_save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
remove_column :custom_workflows, :after_save
|
change_table(:custom_workflows, bulk: true) do |t|
|
||||||
rename_column :custom_workflows, :before_save, :script
|
t.remove :after_save
|
||||||
|
t.rename :before_save, :script
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# encoding: utf-8
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
@ -19,10 +19,10 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
# Add column
|
||||||
class AddIsForAllToCustomWorkflows < ActiveRecord::Migration[4.2]
|
class AddIsForAllToCustomWorkflows < ActiveRecord::Migration[4.2]
|
||||||
|
|
||||||
def change
|
def change
|
||||||
add_column :custom_workflows, :is_for_all, :boolean, null: false, default: false
|
add_column :custom_workflows, :is_for_all, :boolean,
|
||||||
|
null: false, default: false
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# encoding: utf-8
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
@ -19,11 +19,12 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
# Modify columns
|
||||||
class MakeAfterSaveAndBeforeSaveNullable < ActiveRecord::Migration[4.2]
|
class MakeAfterSaveAndBeforeSaveNullable < ActiveRecord::Migration[4.2]
|
||||||
|
|
||||||
def up
|
def up
|
||||||
change_column :custom_workflows, :before_save, :text, null: true, default: nil
|
change_table(:custom_workflows, bulk: true) do |t|
|
||||||
change_column :custom_workflows, :after_save, :text, null: true, default: nil
|
t.change :before_save, :text, null: true, default: nil
|
||||||
|
t.change :after_save, :text, null: true, default: nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# encoding: utf-8
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
@ -19,10 +19,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
# Modify the column position
|
||||||
class SetPositionFieldNullable < ActiveRecord::Migration[4.2]
|
class SetPositionFieldNullable < ActiveRecord::Migration[4.2]
|
||||||
|
|
||||||
def up
|
def up
|
||||||
change_column :custom_workflows, :position, :integer, null: true
|
change_column :custom_workflows, :position, :integer, null: true
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
29
db/migrate/20150525083345_add_author_to_custom_workflows.rb
Normal file
29
db/migrate/20150525083345_add_author_to_custom_workflows.rb
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
#
|
||||||
|
# Redmine plugin for Custom Workflows
|
||||||
|
#
|
||||||
|
# Copyright © 2015-19 Anton Argirov
|
||||||
|
# Copyright © 2019-23 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.
|
||||||
|
|
||||||
|
# Add timestamp
|
||||||
|
class AddAuthorToCustomWorkflows < ActiveRecord::Migration[4.2]
|
||||||
|
def change
|
||||||
|
change_table(:custom_workflows, bulk: true) do |t|
|
||||||
|
t.string :author, null: true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -1,4 +1,4 @@
|
|||||||
# encoding: utf-8
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
@ -19,27 +19,29 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
# Add an example
|
||||||
class CreateExampleWorkflow < ActiveRecord::Migration[4.2]
|
class CreateExampleWorkflow < ActiveRecord::Migration[4.2]
|
||||||
|
|
||||||
def up
|
def up
|
||||||
CustomWorkflow.reset_column_information
|
CustomWorkflow.reset_column_information
|
||||||
name = 'Duration/Done Ratio/Status correlation'
|
name = 'Duration/Done Ratio/Status correlation'
|
||||||
old = CustomWorkflow.where(name: name).first
|
old = CustomWorkflow.where(name: name).first
|
||||||
old.destroy if old
|
old&.destroy
|
||||||
cw = CustomWorkflow.new
|
cw = CustomWorkflow.new
|
||||||
cw.name = name
|
cw.name = name
|
||||||
cw.author = 'anton.argirov@gmail.com'
|
cw.author = 'anton.argirov@gmail.com'
|
||||||
cw.description = %{
|
cw.description = %(
|
||||||
Set up a correlation between the start date, due date, done ratio and status of issues.
|
Set up a correlation between the start date, due date, done ratio and status of issues.
|
||||||
|
|
||||||
* If done ratio is changed to 100% and status is "In Process", status changes to "Resolved"
|
* If done ratio is changed to 100% and status is "In Process", status changes to "Resolved"
|
||||||
* If status is "New", "Resolved" or "Feedback" and done ratio is changed to value less than 100%, status changes to "In process"
|
* If status is "New", "Resolved" or "Feedback" and done ratio is changed to value less than 100%, status changes
|
||||||
|
to "In process"
|
||||||
* If status is changed to "In process" and start date is not set, then it sets to current date
|
* If status is changed to "In process" and start date is not set, then it sets to current date
|
||||||
* If status is changed to "Resolved" and end date is not set, then it set to due date
|
* If status is changed to "Resolved" and end date is not set, then it set to due date
|
||||||
|
|
||||||
To use this script properly, turn off "Use current date as start date for new issues" option in the settings as this script already do it own way.
|
To use this script properly, turn off "Use current date as start date for new issues" option in the settings as
|
||||||
}
|
this script already do it own way.
|
||||||
cw.before_save = %{
|
)
|
||||||
|
cw.before_save = %(
|
||||||
if @issue.done_ratio_changed?
|
if @issue.done_ratio_changed?
|
||||||
if (@issue.done_ratio == 100) && (@issue.status_id == 2)
|
if (@issue.done_ratio == 100) && (@issue.status_id == 2)
|
||||||
@issue.status_id = 3
|
@issue.status_id = 3
|
||||||
@ -58,8 +60,7 @@ class CreateExampleWorkflow < ActiveRecord::Migration[4.2]
|
|||||||
@issue.due_date ||= Time.now
|
@issue.due_date ||= Time.now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
)
|
||||||
cw.save!
|
cw.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# encoding: utf-8
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
@ -19,10 +19,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
# Extend custom_workflows table
|
||||||
class AddActiveFieldToCustomWorkflows < ActiveRecord::Migration[4.2]
|
class AddActiveFieldToCustomWorkflows < ActiveRecord::Migration[4.2]
|
||||||
|
|
||||||
def change
|
def change
|
||||||
add_column :custom_workflows, :active, :boolean, null: false, default: true
|
add_column :custom_workflows, :active, :boolean, null: false, default: true
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# encoding: utf-8
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
@ -19,10 +19,10 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
# Extend custom_workflows table
|
||||||
class AddObservableFieldToCustomWorkflows < ActiveRecord::Migration[4.2]
|
class AddObservableFieldToCustomWorkflows < ActiveRecord::Migration[4.2]
|
||||||
|
|
||||||
def change
|
def change
|
||||||
add_column :custom_workflows, :observable, :string, null: false, default: 'issue'
|
add_column :custom_workflows, :observable, :string,
|
||||||
|
null: false, default: 'issue'
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# encoding: utf-8
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
@ -19,14 +19,15 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
# Extend custom workflows table
|
||||||
class AddAdditionalScriptFieldsToCustomWorkflows < ActiveRecord::Migration[4.2]
|
class AddAdditionalScriptFieldsToCustomWorkflows < ActiveRecord::Migration[4.2]
|
||||||
|
|
||||||
def change
|
def change
|
||||||
add_column :custom_workflows, :shared_code, :text, null: true
|
change_table(:custom_workflows, bulk: true) do |t|
|
||||||
add_column :custom_workflows, :before_add, :text, null: true
|
t.text :shared_code, null: true
|
||||||
add_column :custom_workflows, :after_add, :text, null: true
|
t.text :before_add, null: true
|
||||||
add_column :custom_workflows, :before_remove, :text, null: true
|
t.text :after_add, null: true
|
||||||
add_column :custom_workflows, :after_remove, :text, null: true
|
t.text :before_remove, null: true
|
||||||
|
t.text :after_remove, null: true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# encoding: utf-8
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
@ -19,11 +19,12 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
# Extend custom_workflows table
|
||||||
class AddBeforeAndAfterDestroyToCustomWorkflows < ActiveRecord::Migration[4.2]
|
class AddBeforeAndAfterDestroyToCustomWorkflows < ActiveRecord::Migration[4.2]
|
||||||
|
|
||||||
def change
|
def change
|
||||||
add_column :custom_workflows, :before_destroy, :text, null: true
|
change_table(:custom_workflows, bulk: true) do |t|
|
||||||
add_column :custom_workflows, :after_destroy, :text, null: true
|
t.text :before_destroy, null: true
|
||||||
|
t.text :after_destroy, null: true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# encoding: utf-8
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
#
|
#
|
||||||
@ -19,21 +19,21 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
# SQLite boolean migration
|
||||||
class ChangeDefaultActiveBooleanValueToCustomWorkflows < ActiveRecord::Migration[4.2]
|
class ChangeDefaultActiveBooleanValueToCustomWorkflows < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
if ActiveRecord::Base.connection.adapter_name =~ /sqlite/i
|
return unless ActiveRecord::Base.connection.adapter_name.match?(/sqlite/i)
|
||||||
change_column_default :custom_workflows, :active, from: true, to: 1
|
|
||||||
CustomWorkflow.where("active = 't'").update_all(active: 1)
|
change_column_default :custom_workflows, :active, from: true, to: 1
|
||||||
CustomWorkflow.where("active = 'f'").update_all(active: 0)
|
CustomWorkflow.where(active: 't').each { |w| w.update(active: 1) }
|
||||||
end
|
CustomWorkflow.where(active: 'f').each { |w| w.update(active: 0) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
if ActiveRecord::Base.connection.adapter_name =~ /sqlite/i
|
return unless ActiveRecord::Base.connection.adapter_name.match?(/sqlite/i)
|
||||||
change_column_default :custom_workflows, :active, from: 1, to: true
|
|
||||||
CustomWorkflow.where("active = 1").update_all(active: 't')
|
|
||||||
CustomWorkflow.where("active = 0").update_all(active: 'f')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
change_column_default :custom_workflows, :active, from: 1, to: true
|
||||||
|
CustomWorkflow.where(active: 1).each { |w| w.update(active: 't') }
|
||||||
|
CustomWorkflow.where(active: 0).each { |w| w.update(active: 'f') }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
27
db/migrate/20230413125201_name_unique_index.rb
Normal file
27
db/migrate/20230413125201_name_unique_index.rb
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
#
|
||||||
|
# Redmine plugin for Custom Workflows
|
||||||
|
#
|
||||||
|
# Copyright © 2015-19 Anton Argirov
|
||||||
|
# Copyright © 2019-20 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.
|
||||||
|
|
||||||
|
# Unique index on name
|
||||||
|
class NameUniqueIndex < ActiveRecord::Migration[4.2]
|
||||||
|
def change
|
||||||
|
add_index :custom_workflows, :name, unique: true
|
||||||
|
end
|
||||||
|
end
|
||||||
5
init.rb
5
init.rb
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -33,6 +32,4 @@ Redmine::Plugin.register :redmine_custom_workflows do
|
|||||||
permission :manage_project_workflow, {}, require: :member
|
permission :manage_project_workflow, {}, require: :member
|
||||||
end
|
end
|
||||||
|
|
||||||
unless Redmine::Plugin.installed?(:easy_extensions)
|
require_relative 'after_init' unless Redmine::Plugin.installed?('easy_extensions')
|
||||||
require_relative 'after_init'
|
|
||||||
end
|
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -21,35 +20,35 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
# Hooks
|
# Hooks
|
||||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/hooks/views/base_view_hooks'
|
require "#{File.dirname(__FILE__)}/redmine_custom_workflows/hooks/views/base_view_hooks"
|
||||||
|
|
||||||
# Errors
|
# Errors
|
||||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/errors/workflow_error'
|
require "#{File.dirname(__FILE__)}/redmine_custom_workflows/errors/workflow_error"
|
||||||
|
|
||||||
# Patches
|
# Patches
|
||||||
|
|
||||||
# Models
|
# Models
|
||||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/models/attachment_patch'
|
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/group_patch"
|
||||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/models/issue_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/issue_relation_patch"
|
||||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/models/project_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/time_entry_patch"
|
||||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/models/user_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/version_patch"
|
||||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/models/wiki_content_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'
|
require "#{File.dirname(__FILE__)}/redmine_custom_workflows/patches/models/wiki_page_patch"
|
||||||
|
|
||||||
# Controllers
|
# Controllers
|
||||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/controllers/issues_controller_patch'
|
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/attachments_controller_patch"
|
||||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/controllers/groups_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/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/projects_controller_patch"
|
||||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/controllers/timelog_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/users_controller_patch"
|
||||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/controllers/versions_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'
|
require "#{File.dirname(__FILE__)}/redmine_custom_workflows/patches/controllers/wiki_controller_patch"
|
||||||
|
|
||||||
# Helpers
|
# Helpers
|
||||||
require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/helpers/projects_helper_patch'
|
require "#{File.dirname(__FILE__)}/redmine_custom_workflows/patches/helpers/projects_helper_patch"
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -22,10 +21,7 @@
|
|||||||
|
|
||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Errors
|
module Errors
|
||||||
|
|
||||||
class WorkflowError < StandardError
|
class WorkflowError < StandardError
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,16 +22,14 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Hooks
|
module Hooks
|
||||||
module Views
|
module Views
|
||||||
|
# Base view hooks
|
||||||
class BaseViewHooks < Redmine::Hook::ViewListener
|
class BaseViewHooks < Redmine::Hook::ViewListener
|
||||||
|
def view_layouts_base_html_head(context = {})
|
||||||
def view_layouts_base_html_head(context={})
|
|
||||||
return unless /^(CustomWorkflows|Projects)/.match?(context[:controller].class.name)
|
return unless /^(CustomWorkflows|Projects)/.match?(context[:controller].class.name)
|
||||||
|
|
||||||
"\n".html_safe + stylesheet_link_tag('custom_workflows.css', plugin: :redmine_custom_workflows)
|
"\n".html_safe + stylesheet_link_tag('custom_workflows.css', plugin: :redmine_custom_workflows)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,8 +22,8 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Patches
|
module Patches
|
||||||
module Controllers
|
module Controllers
|
||||||
|
# Attachments controller patch
|
||||||
module AttachmentsControllerPatch
|
module AttachmentsControllerPatch
|
||||||
|
|
||||||
################################################################################################################
|
################################################################################################################
|
||||||
# New methods
|
# New methods
|
||||||
#
|
#
|
||||||
@ -37,46 +36,44 @@ module RedmineCustomWorkflows
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_env
|
def set_env
|
||||||
objects = get_model_objects
|
objects = model_objects
|
||||||
if objects&.any?
|
return unless objects&.any?
|
||||||
objects.each do |o|
|
|
||||||
o.custom_workflow_env[:remote_ip] = request.remote_ip
|
objects.each do |o|
|
||||||
end
|
o.custom_workflow_env[:remote_ip] = request.remote_ip
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def display_custom_workflow_messages
|
def display_custom_workflow_messages
|
||||||
objects = get_model_objects
|
objects = model_objects
|
||||||
if objects&.any?
|
return unless objects&.any?
|
||||||
objects.each do |o|
|
|
||||||
if o&.custom_workflow_messages&.any?
|
objects.each do |o|
|
||||||
o.custom_workflow_messages.each do |key, value|
|
next if o&.custom_workflow_messages&.empty?
|
||||||
unless value&.present?
|
|
||||||
flash.delete key
|
o.custom_workflow_messages.each do |key, value|
|
||||||
else
|
if value&.present?
|
||||||
flash[key] = value
|
flash[key] = value
|
||||||
end
|
else
|
||||||
end
|
flash.delete key
|
||||||
o.custom_workflow_messages = {}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
o.custom_workflow_messages.clear
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_model_objects
|
def model_objects
|
||||||
if @attachments
|
if @attachments
|
||||||
objects = @attachments
|
@attachments
|
||||||
elsif @attachment
|
elsif @attachment
|
||||||
objects = [@attachment]
|
[@attachment]
|
||||||
end
|
end
|
||||||
objects
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
AttachmentsController.send :prepend, RedmineCustomWorkflows::Patches::Controllers::AttachmentsControllerPatch
|
AttachmentsController.prepend RedmineCustomWorkflows::Patches::Controllers::AttachmentsControllerPatch
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,8 +22,8 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Patches
|
module Patches
|
||||||
module Controllers
|
module Controllers
|
||||||
|
# Groups controller patch
|
||||||
module GroupsControllerPatch
|
module GroupsControllerPatch
|
||||||
|
|
||||||
################################################################################################################
|
################################################################################################################
|
||||||
# New methods
|
# New methods
|
||||||
#
|
#
|
||||||
@ -37,46 +36,44 @@ module RedmineCustomWorkflows
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_env
|
def set_env
|
||||||
objects = get_model_objects
|
objects = model_objects
|
||||||
if objects&.any?
|
return unless objects&.any?
|
||||||
objects.each do |o|
|
|
||||||
o.custom_workflow_env[:remote_ip] = request.remote_ip
|
objects.each do |o|
|
||||||
end
|
o.custom_workflow_env[:remote_ip] = request.remote_ip
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def display_custom_workflow_messages
|
def display_custom_workflow_messages
|
||||||
objects = get_model_objects
|
objects = model_objects
|
||||||
if objects&.any?
|
return unless objects&.any?
|
||||||
objects.each do |o|
|
|
||||||
if o&.custom_workflow_messages&.any?
|
objects.each do |o|
|
||||||
o.custom_workflow_messages.each do |key, value|
|
next if o&.custom_workflow_messages&.empty?
|
||||||
unless value&.present?
|
|
||||||
flash.delete key
|
o.custom_workflow_messages.each do |key, value|
|
||||||
else
|
if value&.present?
|
||||||
flash[key] = value
|
flash[key] = value
|
||||||
end
|
else
|
||||||
end
|
flash.delete key
|
||||||
o.custom_workflow_messages = {}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
o.custom_workflow_messages.clear
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_model_objects
|
def model_objects
|
||||||
if @groups
|
if @groups
|
||||||
objects = @groups
|
@groups
|
||||||
elsif @group
|
elsif @group
|
||||||
objects = [@group]
|
[@group]
|
||||||
end
|
end
|
||||||
objects
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
GroupsController.send :prepend, RedmineCustomWorkflows::Patches::Controllers::GroupsControllerPatch
|
GroupsController.prepend RedmineCustomWorkflows::Patches::Controllers::GroupsControllerPatch
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,8 +22,8 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Patches
|
module Patches
|
||||||
module Controllers
|
module Controllers
|
||||||
|
# Issue relations controller patch
|
||||||
module IssueRelationsControllerPatch
|
module IssueRelationsControllerPatch
|
||||||
|
|
||||||
################################################################################################################
|
################################################################################################################
|
||||||
# New methods
|
# New methods
|
||||||
#
|
#
|
||||||
@ -37,46 +36,44 @@ module RedmineCustomWorkflows
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_env
|
def set_env
|
||||||
objects = get_model_objects
|
objects = model_objects
|
||||||
if objects&.any?
|
return unless objects&.any?
|
||||||
objects.each do |o|
|
|
||||||
o.custom_workflow_env[:remote_ip] = request.remote_ip
|
objects.each do |o|
|
||||||
end
|
o.custom_workflow_env[:remote_ip] = request.remote_ip
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def display_custom_workflow_messages
|
def display_custom_workflow_messages
|
||||||
objects = get_model_objects
|
objects = model_objects
|
||||||
if objects&.any?
|
return unless objects&.any?
|
||||||
objects.each do |o|
|
|
||||||
if o&.custom_workflow_messages&.any?
|
objects.each do |o|
|
||||||
o.custom_workflow_messages.each do |key, value|
|
next if o&.custom_workflow_messages&.empty?
|
||||||
unless value&.present?
|
|
||||||
flash.delete key
|
o.custom_workflow_messages.each do |key, value|
|
||||||
else
|
if value&.present?
|
||||||
flash[key] = value
|
flash[key] = value
|
||||||
end
|
else
|
||||||
end
|
flash.delete key
|
||||||
o.custom_workflow_messages = {}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
o.custom_workflow_messages.clear
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_model_objects
|
def model_objects
|
||||||
if @relations
|
if @relations
|
||||||
objects = @relations
|
@relations
|
||||||
elsif @relation
|
elsif @relation
|
||||||
objects = [@relation]
|
[@relation]
|
||||||
end
|
end
|
||||||
objects
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
IssueRelationsController.send :prepend, RedmineCustomWorkflows::Patches::Controllers::IssueRelationsControllerPatch
|
IssueRelationsController.prepend RedmineCustomWorkflows::Patches::Controllers::IssueRelationsControllerPatch
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,8 +22,8 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Patches
|
module Patches
|
||||||
module Controllers
|
module Controllers
|
||||||
|
# Issues controller patch
|
||||||
module IssuesControllerPatch
|
module IssuesControllerPatch
|
||||||
|
|
||||||
################################################################################################################
|
################################################################################################################
|
||||||
# New methods
|
# New methods
|
||||||
#
|
#
|
||||||
@ -37,46 +36,44 @@ module RedmineCustomWorkflows
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_env
|
def set_env
|
||||||
objects = get_model_objects
|
objects = model_objects
|
||||||
if objects&.any?
|
return unless objects&.any?
|
||||||
objects.each do |o|
|
|
||||||
o.custom_workflow_env[:remote_ip] = request.remote_ip
|
objects.each do |o|
|
||||||
end
|
o.custom_workflow_env[:remote_ip] = request.remote_ip
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def display_custom_workflow_messages
|
def display_custom_workflow_messages
|
||||||
objects = get_model_objects
|
objects = model_objects
|
||||||
if objects&.any?
|
return unless objects&.any?
|
||||||
objects.each do |o|
|
|
||||||
if o&.custom_workflow_messages&.any?
|
objects.each do |o|
|
||||||
o.custom_workflow_messages.each do |key, value|
|
next if o&.custom_workflow_messages&.empty?
|
||||||
unless value&.present?
|
|
||||||
flash.delete key
|
o.custom_workflow_messages.each do |key, value|
|
||||||
else
|
if value&.present?
|
||||||
flash[key] = value
|
flash[key] = value
|
||||||
end
|
else
|
||||||
end
|
flash.delete key
|
||||||
o.custom_workflow_messages = {}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
o.custom_workflow_messages.clear
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_model_objects
|
def model_objects
|
||||||
if @issues
|
if @issues
|
||||||
objects = @issues
|
@issues
|
||||||
elsif @issue
|
elsif @issue
|
||||||
objects = [@issue]
|
[@issue]
|
||||||
end
|
end
|
||||||
objects
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
IssuesController.send :prepend, RedmineCustomWorkflows::Patches::Controllers::IssuesControllerPatch
|
IssuesController.prepend RedmineCustomWorkflows::Patches::Controllers::IssuesControllerPatch
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,8 +22,8 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Patches
|
module Patches
|
||||||
module Controllers
|
module Controllers
|
||||||
|
# Projects controller patch
|
||||||
module ProjectsControllerPatch
|
module ProjectsControllerPatch
|
||||||
|
|
||||||
################################################################################################################
|
################################################################################################################
|
||||||
# New methods
|
# New methods
|
||||||
#
|
#
|
||||||
@ -37,46 +36,44 @@ module RedmineCustomWorkflows
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_env
|
def set_env
|
||||||
objects = get_model_objects
|
objects = model_objects
|
||||||
if objects&.any?
|
return unless objects&.any?
|
||||||
objects.each do |o|
|
|
||||||
o.custom_workflow_env[:remote_ip] = request.remote_ip
|
objects.each do |o|
|
||||||
end
|
o.custom_workflow_env[:remote_ip] = request.remote_ip
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def display_custom_workflow_messages
|
def display_custom_workflow_messages
|
||||||
objects = get_model_objects
|
objects = model_objects
|
||||||
if objects&.any?
|
return unless objects&.any?
|
||||||
objects.each do |o|
|
|
||||||
if o&.custom_workflow_messages&.any?
|
objects.each do |o|
|
||||||
o.custom_workflow_messages.each do |key, value|
|
next if o&.custom_workflow_messages&.empty?
|
||||||
unless value&.present?
|
|
||||||
flash.delete key
|
o.custom_workflow_messages.each do |key, value|
|
||||||
else
|
if value&.present?
|
||||||
flash[key] = value
|
flash[key] = value
|
||||||
end
|
else
|
||||||
end
|
flash.delete key
|
||||||
o.custom_workflow_messages = {}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
o.custom_workflow_messages.clear
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_model_objects
|
def model_objects
|
||||||
if @projects
|
if @projects
|
||||||
objects = @projects
|
@projects
|
||||||
elsif @project
|
elsif @project
|
||||||
objects = [@project]
|
[@project]
|
||||||
end
|
end
|
||||||
objects
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ProjectsController.send :prepend, RedmineCustomWorkflows::Patches::Controllers::ProjectsControllerPatch
|
ProjectsController.prepend RedmineCustomWorkflows::Patches::Controllers::ProjectsControllerPatch
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,8 +22,8 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Patches
|
module Patches
|
||||||
module Controllers
|
module Controllers
|
||||||
|
# Timelog controller patch
|
||||||
module TimelogControllerPatch
|
module TimelogControllerPatch
|
||||||
|
|
||||||
################################################################################################################
|
################################################################################################################
|
||||||
# New methods
|
# New methods
|
||||||
#
|
#
|
||||||
@ -37,46 +36,44 @@ module RedmineCustomWorkflows
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_env
|
def set_env
|
||||||
objects = get_model_objects
|
objects = model_objects
|
||||||
if objects&.any?
|
return unless objects&.any?
|
||||||
objects.each do |o|
|
|
||||||
o.custom_workflow_env[:remote_ip] = request.remote_ip
|
objects.each do |o|
|
||||||
end
|
o.custom_workflow_env[:remote_ip] = request.remote_ip
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def display_custom_workflow_messages
|
def display_custom_workflow_messages
|
||||||
objects = get_model_objects
|
objects = model_objects
|
||||||
if objects&.any?
|
return unless objects&.any?
|
||||||
objects.each do |o|
|
|
||||||
if o&.custom_workflow_messages&.any?
|
objects.each do |o|
|
||||||
o.custom_workflow_messages.each do |key, value|
|
next if o&.custom_workflow_messages&.empty?
|
||||||
unless value&.present?
|
|
||||||
flash.delete key
|
o.custom_workflow_messages.each do |key, value|
|
||||||
else
|
if value&.present?
|
||||||
flash[key] = value
|
flash[key] = value
|
||||||
end
|
else
|
||||||
end
|
flash.delete key
|
||||||
o.custom_workflow_messages = {}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
o.custom_workflow_messages.clear
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_model_objects
|
def model_objects
|
||||||
if @time_entries
|
if @time_entries
|
||||||
objects = @time_entries
|
@time_entries
|
||||||
elsif @time_entry
|
elsif @time_entry
|
||||||
objects = [@time_entry]
|
[@time_entry]
|
||||||
end
|
end
|
||||||
objects
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
TimelogController.send :prepend, RedmineCustomWorkflows::Patches::Controllers::TimelogControllerPatch
|
TimelogController.prepend RedmineCustomWorkflows::Patches::Controllers::TimelogControllerPatch
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,8 +22,8 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Patches
|
module Patches
|
||||||
module Controllers
|
module Controllers
|
||||||
|
# Users controller patch
|
||||||
module UsersControllerPatch
|
module UsersControllerPatch
|
||||||
|
|
||||||
################################################################################################################
|
################################################################################################################
|
||||||
# New methods
|
# New methods
|
||||||
#
|
#
|
||||||
@ -37,46 +36,44 @@ module RedmineCustomWorkflows
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_env
|
def set_env
|
||||||
objects = get_model_objects
|
objects = model_objects
|
||||||
if objects&.any?
|
return unless objects&.any?
|
||||||
objects.each do |o|
|
|
||||||
o.custom_workflow_env[:remote_ip] = request.remote_ip
|
objects.each do |o|
|
||||||
end
|
o.custom_workflow_env[:remote_ip] = request.remote_ip
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def display_custom_workflow_messages
|
def display_custom_workflow_messages
|
||||||
objects = get_model_objects
|
objects = model_objects
|
||||||
if objects&.any?
|
return unless objects&.any?
|
||||||
objects.each do |o|
|
|
||||||
if o&.custom_workflow_messages&.any?
|
objects.each do |o|
|
||||||
o.custom_workflow_messages.each do |key, value|
|
next if o&.custom_workflow_messages&.empty?
|
||||||
unless value&.present?
|
|
||||||
flash.delete key
|
o.custom_workflow_messages.each do |key, value|
|
||||||
else
|
if value&.present?
|
||||||
flash[key] = value
|
flash[key] = value
|
||||||
end
|
else
|
||||||
end
|
flash.delete key
|
||||||
o.custom_workflow_messages = {}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
o.custom_workflow_messages.clear
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_model_objects
|
def model_objects
|
||||||
if @users
|
if @users
|
||||||
objects = @users
|
@users
|
||||||
elsif @user
|
elsif @user
|
||||||
objects = [@user]
|
[@user]
|
||||||
end
|
end
|
||||||
objects
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
UsersController.send :prepend, RedmineCustomWorkflows::Patches::Controllers::UsersControllerPatch
|
UsersController.prepend RedmineCustomWorkflows::Patches::Controllers::UsersControllerPatch
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,8 +22,8 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Patches
|
module Patches
|
||||||
module Controllers
|
module Controllers
|
||||||
|
# Versions controller patch
|
||||||
module VersionsControllerPatch
|
module VersionsControllerPatch
|
||||||
|
|
||||||
################################################################################################################
|
################################################################################################################
|
||||||
# New methods
|
# New methods
|
||||||
#
|
#
|
||||||
@ -37,45 +36,44 @@ module RedmineCustomWorkflows
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_env
|
def set_env
|
||||||
objects = get_model_objects
|
objects = model_objects
|
||||||
if objects&.any?
|
return unless objects&.any?
|
||||||
objects.each do |o|
|
|
||||||
o.custom_workflow_env[:remote_ip] = request.remote_ip
|
objects.each do |o|
|
||||||
end
|
o.custom_workflow_env[:remote_ip] = request.remote_ip
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def display_custom_workflow_messages
|
def display_custom_workflow_messages
|
||||||
objects = get_model_objects
|
objects = model_objects
|
||||||
if objects&.any?
|
return unless objects&.any?
|
||||||
objects.each do |o|
|
|
||||||
if o&.custom_workflow_messages&.any?
|
objects.each do |o|
|
||||||
o.custom_workflow_messages.each do |key, value|
|
next if o&.custom_workflow_messages&.empty?
|
||||||
unless value&.present?
|
|
||||||
flash.delete key
|
o.custom_workflow_messages.each do |key, value|
|
||||||
else
|
if value&.present?
|
||||||
flash[key] = value
|
flash[key] = value
|
||||||
end
|
else
|
||||||
end
|
flash.delete key
|
||||||
o.custom_workflow_messages = {}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
o.custom_workflow_messages.clear
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_model_objects
|
def model_objects
|
||||||
if @versions
|
if @versions
|
||||||
objects = @versions
|
@versions
|
||||||
elsif @version
|
elsif @version
|
||||||
objects = [@version]
|
[@version]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
VersionsController.send :prepend, RedmineCustomWorkflows::Patches::Controllers::VersionsControllerPatch
|
VersionsController.prepend RedmineCustomWorkflows::Patches::Controllers::VersionsControllerPatch
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,8 +22,8 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Patches
|
module Patches
|
||||||
module Controllers
|
module Controllers
|
||||||
|
# Wiki controller patch
|
||||||
module WikiControllerPatch
|
module WikiControllerPatch
|
||||||
|
|
||||||
################################################################################################################
|
################################################################################################################
|
||||||
# New methods
|
# New methods
|
||||||
#
|
#
|
||||||
@ -37,37 +36,35 @@ module RedmineCustomWorkflows
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_env
|
def set_env
|
||||||
objects = get_model_objects
|
objects = model_objects
|
||||||
if objects&.any?
|
return unless objects&.any?
|
||||||
objects.each do |o|
|
|
||||||
if request.remote_ip.present?
|
objects.each do |o|
|
||||||
o.custom_workflow_env[:remote_ip] = request.remote_ip
|
o.custom_workflow_env[:remote_ip] = request.remote_ip if request.remote_ip.present?
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def display_custom_workflow_messages
|
def display_custom_workflow_messages
|
||||||
objects = get_model_objects
|
objects = model_objects
|
||||||
if objects&.any?
|
return unless objects&.any?
|
||||||
objects.each do |o|
|
|
||||||
if o&.custom_workflow_messages&.any?
|
objects.each do |o|
|
||||||
o.custom_workflow_messages.each do |key, value|
|
next if o&.custom_workflow_messages&.empty?
|
||||||
unless value&.present?
|
|
||||||
flash.delete key
|
o.custom_workflow_messages.each do |key, value|
|
||||||
else
|
if value&.present?
|
||||||
flash[key] = value
|
flash[key] = value
|
||||||
end
|
else
|
||||||
end
|
flash.delete key
|
||||||
o.custom_workflow_messages = {}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
o.custom_workflow_messages.clear
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_model_objects
|
def model_objects
|
||||||
if @pages
|
if @pages
|
||||||
objects = @pages
|
objects = @pages
|
||||||
elsif @page
|
elsif @page
|
||||||
@ -81,10 +78,9 @@ module RedmineCustomWorkflows
|
|||||||
end
|
end
|
||||||
objects
|
objects
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
WikiController.send :prepend, RedmineCustomWorkflows::Patches::Controllers::WikiControllerPatch
|
WikiController.prepend RedmineCustomWorkflows::Patches::Controllers::WikiControllerPatch
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,24 +22,30 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Patches
|
module Patches
|
||||||
module Helpers
|
module Helpers
|
||||||
|
# Project helper patch
|
||||||
module ProjectsHelperPatch
|
module ProjectsHelperPatch
|
||||||
|
|
||||||
def project_settings_tabs
|
def project_settings_tabs
|
||||||
tabs = super
|
tabs = super
|
||||||
tabs << { name: 'custom_workflows', action: :manage_project_workflow, partial: 'projects/settings/custom_workflow',
|
if User.current.allowed_to?(:manage_project_workflow, @project)
|
||||||
label: :label_custom_workflow_plural } if User.current.allowed_to?(:manage_project_workflow, @project)
|
tabs << {
|
||||||
|
name: 'custom_workflows',
|
||||||
|
action: :manage_project_workflow,
|
||||||
|
partial: 'projects/settings/custom_workflow',
|
||||||
|
label: :label_custom_workflow_plural
|
||||||
|
}
|
||||||
|
end
|
||||||
tabs
|
tabs
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Apply the patch
|
# Apply the patch
|
||||||
if Redmine::Plugin.installed?(:easy_extensions)
|
if Redmine::Plugin.installed?('easy_extensions')
|
||||||
RedmineExtensions::PatchManager.register_helper_patch 'ProjectsHelper',
|
RedmineExtensions::PatchManager.register_helper_patch 'ProjectsHelper',
|
||||||
'RedmineCustomWorkflows::Patches::Helpers::ProjectsHelperPatch', prepend: true
|
'RedmineCustomWorkflows::Patches::Helpers::ProjectsHelperPatch',
|
||||||
|
prepend: true
|
||||||
else
|
else
|
||||||
ProjectsController.send :helper, RedmineCustomWorkflows::Patches::Helpers::ProjectsHelperPatch
|
ProjectsController.send :helper, RedmineCustomWorkflows::Patches::Helpers::ProjectsHelperPatch
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,11 +22,8 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Patches
|
module Patches
|
||||||
module Models
|
module Models
|
||||||
|
# Attachment model patch
|
||||||
module AttachmentPatch
|
module AttachmentPatch
|
||||||
|
|
||||||
attr_accessor 'custom_workflow_messages'
|
|
||||||
attr_accessor 'custom_workflow_env'
|
|
||||||
|
|
||||||
def custom_workflow_messages
|
def custom_workflow_messages
|
||||||
@custom_workflow_messages ||= {}
|
@custom_workflow_messages ||= {}
|
||||||
end
|
end
|
||||||
@ -51,6 +47,7 @@ module RedmineCustomWorkflows
|
|||||||
CustomWorkflow.run_shared_code self
|
CustomWorkflow.run_shared_code self
|
||||||
CustomWorkflow.run_custom_workflows :attachment, self, :before_save
|
CustomWorkflow.run_custom_workflows :attachment, self, :before_save
|
||||||
throw :abort if errors.any?
|
throw :abort if errors.any?
|
||||||
|
|
||||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||||
ensure
|
ensure
|
||||||
@saved_attributes = nil
|
@saved_attributes = nil
|
||||||
@ -62,24 +59,21 @@ module RedmineCustomWorkflows
|
|||||||
|
|
||||||
def before_destroy_custom_workflows
|
def before_destroy_custom_workflows
|
||||||
res = CustomWorkflow.run_custom_workflows :attachment, self, :before_destroy
|
res = CustomWorkflow.run_custom_workflows :attachment, self, :before_destroy
|
||||||
if res == false
|
throw :abort if res == false
|
||||||
throw :abort
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_destroy_custom_workflows
|
def after_destroy_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :attachment, self, :after_destroy
|
CustomWorkflow.run_custom_workflows :attachment, self, :after_destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Apply the patch
|
# Apply the patch
|
||||||
if Redmine::Plugin.installed?(:easy_extensions)
|
if Redmine::Plugin.installed?('easy_extensions')
|
||||||
RedmineExtensions::PatchManager.register_model_patch 'Attachment',
|
RedmineExtensions::PatchManager.register_model_patch 'Attachment',
|
||||||
'RedmineCustomWorkflows::Patches::Models::AttachmentPatch'
|
'RedmineCustomWorkflows::Patches::Models::AttachmentPatch'
|
||||||
else
|
else
|
||||||
Attachment.prepend RedmineCustomWorkflows::Patches::Models::AttachmentPatch
|
Attachment.prepend RedmineCustomWorkflows::Patches::Models::AttachmentPatch
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,11 +22,8 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Patches
|
module Patches
|
||||||
module Models
|
module Models
|
||||||
|
# Group model patch
|
||||||
module GroupPatch
|
module GroupPatch
|
||||||
|
|
||||||
attr_accessor 'custom_workflow_messages'
|
|
||||||
attr_accessor 'custom_workflow_env'
|
|
||||||
|
|
||||||
def custom_workflow_messages
|
def custom_workflow_messages
|
||||||
@custom_workflow_messages ||= {}
|
@custom_workflow_messages ||= {}
|
||||||
end
|
end
|
||||||
@ -49,11 +45,15 @@ module RedmineCustomWorkflows
|
|||||||
CustomWorkflow.run_shared_code(group) if event.to_s.starts_with? 'before_'
|
CustomWorkflow.run_shared_code(group) if event.to_s.starts_with? 'before_'
|
||||||
CustomWorkflow.run_custom_workflows :group_users, group, event
|
CustomWorkflow.run_custom_workflows :group_users, group, event
|
||||||
end
|
end
|
||||||
[:before_add, :before_remove, :after_add, :after_remove].each do |observable|
|
%i[before_add before_remove after_add after_remove].each do |observable|
|
||||||
send("#{observable}_for_users") << if Rails::VERSION::MAJOR >= 4
|
send("#{observable}_for_users") << if Rails::VERSION::MAJOR >= 4
|
||||||
lambda { |event, group, user| Group.users_callback(event, group, user) }
|
lambda { |event, group, user|
|
||||||
|
Group.users_callback(event, group, user)
|
||||||
|
}
|
||||||
else
|
else
|
||||||
lambda { |group, user| Group.users_callback(observable, group, user) }
|
lambda { |group, user|
|
||||||
|
Group.users_callback(observable, group, user)
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -65,6 +65,7 @@ module RedmineCustomWorkflows
|
|||||||
CustomWorkflow.run_shared_code self
|
CustomWorkflow.run_shared_code self
|
||||||
CustomWorkflow.run_custom_workflows :group, self, :before_save
|
CustomWorkflow.run_custom_workflows :group, self, :before_save
|
||||||
throw :abort if errors.any?
|
throw :abort if errors.any?
|
||||||
|
|
||||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||||
ensure
|
ensure
|
||||||
@saved_attributes = nil
|
@saved_attributes = nil
|
||||||
@ -76,24 +77,20 @@ module RedmineCustomWorkflows
|
|||||||
|
|
||||||
def before_destroy_custom_workflows
|
def before_destroy_custom_workflows
|
||||||
res = CustomWorkflow.run_custom_workflows :group, self, :before_destroy
|
res = CustomWorkflow.run_custom_workflows :group, self, :before_destroy
|
||||||
if res == false
|
throw :abort if res == false
|
||||||
throw :abort
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_destroy_custom_workflows
|
def after_destroy_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :group, self, :after_destroy
|
CustomWorkflow.run_custom_workflows :group, self, :after_destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Apply the patch
|
# Apply the patch
|
||||||
if Redmine::Plugin.installed?(:easy_extensions)
|
if Redmine::Plugin.installed?('easy_extensions')
|
||||||
RedmineExtensions::PatchManager.register_model_patch 'Group',
|
RedmineExtensions::PatchManager.register_model_patch 'Group', 'RedmineCustomWorkflows::Patches::Models::GroupPatch'
|
||||||
'RedmineCustomWorkflows::Patches::Models::GroupPatch'
|
|
||||||
else
|
else
|
||||||
Group.prepend RedmineCustomWorkflows::Patches::Models::GroupPatch
|
Group.prepend RedmineCustomWorkflows::Patches::Models::GroupPatch
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,11 +22,8 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Patches
|
module Patches
|
||||||
module Models
|
module Models
|
||||||
|
# Issue model patch
|
||||||
module IssuePatch
|
module IssuePatch
|
||||||
|
|
||||||
attr_accessor 'custom_workflow_messages'
|
|
||||||
attr_accessor 'custom_workflow_env'
|
|
||||||
|
|
||||||
def custom_workflow_messages
|
def custom_workflow_messages
|
||||||
@custom_workflow_messages ||= {}
|
@custom_workflow_messages ||= {}
|
||||||
end
|
end
|
||||||
@ -51,25 +47,33 @@ module RedmineCustomWorkflows
|
|||||||
CustomWorkflow.run_custom_workflows :issue_attachments, issue, event
|
CustomWorkflow.run_custom_workflows :issue_attachments, issue, event
|
||||||
end
|
end
|
||||||
|
|
||||||
[:before_add, :before_remove, :after_add, :after_remove].each do |observable|
|
%i[before_add before_remove after_add after_remove].each do |observable|
|
||||||
send("#{observable}_for_attachments") << if Rails::VERSION::MAJOR >= 4
|
send("#{observable}_for_attachments") << if Rails::VERSION::MAJOR >= 4
|
||||||
lambda { |event, issue, attachment| Issue.attachments_callback(event, issue, attachment) }
|
lambda { |event, issue, attachment|
|
||||||
|
Issue.attachments_callback event, issue, attachment
|
||||||
|
}
|
||||||
else
|
else
|
||||||
lambda { |issue, attachment| Issue.attachments_callback(observable, issue, attachment) }
|
lambda { |issue, attachment|
|
||||||
|
Issue.attachments_callback observable, issue, attachment
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_status
|
def validate_status
|
||||||
return true unless @saved_attributes && @saved_attributes['status_id'] != status_id &&
|
unless @saved_attributes && (@saved_attributes['status_id'] != status_id) && new_statuses_allowed_to(
|
||||||
!new_statuses_allowed_to(User.current, new_record?).collect(&:id).include?(status_id)
|
User.current, new_record?
|
||||||
status_was = IssueStatus.find_by_id(status_id_was)
|
).collect(&:id).exclude?(status_id)
|
||||||
status_new = IssueStatus.find_by_id(status_id)
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
errors.add :status, :new_status_invalid,
|
status_was = IssueStatus.find_by(id: status_id_was)
|
||||||
old_status: status_was && status_was.name,
|
status_new = IssueStatus.find_by(id: status_id)
|
||||||
new_status: status_new && status_new.name
|
errors.add :status,
|
||||||
|
:new_status_invalid,
|
||||||
|
old_status: status_was&.name,
|
||||||
|
new_status: status_new&.name
|
||||||
end
|
end
|
||||||
|
|
||||||
def before_save_custom_workflows
|
def before_save_custom_workflows
|
||||||
@ -78,6 +82,7 @@ module RedmineCustomWorkflows
|
|||||||
CustomWorkflow.run_shared_code self
|
CustomWorkflow.run_shared_code self
|
||||||
CustomWorkflow.run_custom_workflows :issue, self, :before_save
|
CustomWorkflow.run_custom_workflows :issue, self, :before_save
|
||||||
throw :abort if errors.any?
|
throw :abort if errors.any?
|
||||||
|
|
||||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||||
ensure
|
ensure
|
||||||
@saved_attributes = nil
|
@saved_attributes = nil
|
||||||
@ -89,22 +94,19 @@ module RedmineCustomWorkflows
|
|||||||
|
|
||||||
def before_destroy_custom_workflows
|
def before_destroy_custom_workflows
|
||||||
res = CustomWorkflow.run_custom_workflows(:issue, self, :before_destroy)
|
res = CustomWorkflow.run_custom_workflows(:issue, self, :before_destroy)
|
||||||
if res == false
|
throw :abort if res == false
|
||||||
throw :abort
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_destroy_custom_workflows
|
def after_destroy_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :issue, self, :after_destroy
|
CustomWorkflow.run_custom_workflows :issue, self, :after_destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Apply the patch
|
# Apply the patch
|
||||||
if Redmine::Plugin.installed?(:easy_extensions)
|
if Redmine::Plugin.installed?('easy_extensions')
|
||||||
RedmineExtensions::PatchManager.register_model_patch 'Issue', 'RedmineCustomWorkflows::Patches::Models::IssuePatch'
|
RedmineExtensions::PatchManager.register_model_patch 'Issue', 'RedmineCustomWorkflows::Patches::Models::IssuePatch'
|
||||||
else
|
else
|
||||||
Issue.prepend RedmineCustomWorkflows::Patches::Models::IssuePatch
|
Issue.prepend RedmineCustomWorkflows::Patches::Models::IssuePatch
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,11 +22,8 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Patches
|
module Patches
|
||||||
module Models
|
module Models
|
||||||
|
# Issue relation model patch
|
||||||
module IssueRelationPatch
|
module IssueRelationPatch
|
||||||
|
|
||||||
attr_accessor 'custom_workflow_messages'
|
|
||||||
attr_accessor 'custom_workflow_env'
|
|
||||||
|
|
||||||
def custom_workflow_messages
|
def custom_workflow_messages
|
||||||
@custom_workflow_messages ||= {}
|
@custom_workflow_messages ||= {}
|
||||||
end
|
end
|
||||||
@ -45,27 +41,24 @@ module RedmineCustomWorkflows
|
|||||||
end
|
end
|
||||||
|
|
||||||
base.prepend InstanceMethods
|
base.prepend InstanceMethods
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Instance methods module
|
||||||
module InstanceMethods
|
module InstanceMethods
|
||||||
|
##############################################################################################################
|
||||||
################################################################################################################
|
# Overridden methods
|
||||||
# Overriden methods
|
|
||||||
|
|
||||||
# Override IssueRelation.to_s to rescue NoMethodError during CustomWorkflow.validate_syntax due to
|
# Override IssueRelation.to_s to rescue NoMethodError during CustomWorkflow.validate_syntax due to
|
||||||
# logging of temporarily instatiated IssueRelation with no related issues set.
|
# logging of temporarily instatiated IssueRelation with no related issues set.
|
||||||
def to_s(issue=nil)
|
def to_s(issue = nil)
|
||||||
super
|
super
|
||||||
rescue NoMethodError => e
|
rescue NoMethodError => e
|
||||||
if issue_from.present? || issue_to.present?
|
raise e if issue_from.present? || issue_to.present?
|
||||||
raise e
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
################################################################################################################
|
##############################################################################################################
|
||||||
# New methods
|
# New methods
|
||||||
|
#
|
||||||
def before_save_custom_workflows
|
def before_save_custom_workflows
|
||||||
@issue_relation = self
|
@issue_relation = self
|
||||||
@saved_attributes = attributes.dup
|
@saved_attributes = attributes.dup
|
||||||
@ -83,26 +76,22 @@ module RedmineCustomWorkflows
|
|||||||
|
|
||||||
def before_destroy_custom_workflows
|
def before_destroy_custom_workflows
|
||||||
res = CustomWorkflow.run_custom_workflows :issue_relation, self, :before_destroy
|
res = CustomWorkflow.run_custom_workflows :issue_relation, self, :before_destroy
|
||||||
if res == false
|
throw :abort if res == false
|
||||||
throw :abort
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_destroy_custom_workflows
|
def after_destroy_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :issue_relation, self, :after_destroy
|
CustomWorkflow.run_custom_workflows :issue_relation, self, :after_destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Apply the patch
|
# Apply the patch
|
||||||
if Redmine::Plugin.installed?(:easy_extensions)
|
if Redmine::Plugin.installed?('easy_extensions')
|
||||||
RedmineExtensions::PatchManager.register_model_patch 'IssueRelation',
|
RedmineExtensions::PatchManager.register_model_patch 'IssueRelation',
|
||||||
'RedmineCustomWorkflows::Patches::Models::IssueRelationPatch'
|
'RedmineCustomWorkflows::Patches::Models::IssueRelationPatch'
|
||||||
else
|
else
|
||||||
IssueRelation.prepend RedmineCustomWorkflows::Patches::Models::IssueRelationPatch
|
IssueRelation.prepend RedmineCustomWorkflows::Patches::Models::IssueRelationPatch
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,9 +22,9 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Patches
|
module Patches
|
||||||
module Models
|
module Models
|
||||||
|
# Mailer model patch
|
||||||
module MailerPatch
|
module MailerPatch
|
||||||
|
def self.deliver_custom_email(headers = {})
|
||||||
def self.deliver_custom_email(headers={})
|
|
||||||
user = headers.delete :user
|
user = headers.delete :user
|
||||||
headers[:to] = user.mail if user
|
headers[:to] = user.mail if user
|
||||||
text_body = headers.delete :text_body
|
text_body = headers.delete :text_body
|
||||||
@ -38,23 +37,22 @@ module RedmineCustomWorkflows
|
|||||||
format.html { render text: html_body } if html_body
|
format.html { render text: html_body } if html_body
|
||||||
end
|
end
|
||||||
elsif template_name
|
elsif template_name
|
||||||
template_params.each { |k,v| instance_variable_set("@#{k}", v) }
|
template_params.each { |k, v| instance_variable_set("@#{k}", v) }
|
||||||
mail headers do |format|
|
mail headers do |format|
|
||||||
format.text { render template_name }
|
format.text { render template_name }
|
||||||
format.html { render template_name } unless Setting.plain_text_mail?
|
format.html { render template_name } unless Setting.plain_text_mail?
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
raise StandardError.new('Not :text_body, :html_body or :template_name specified')
|
raise StandardError, 'Not :text_body, :html_body or :template_name specified'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Apply the patch
|
# Apply the patch
|
||||||
if Redmine::Plugin.installed?(:easy_extensions)
|
if Redmine::Plugin.installed?('easy_extensions')
|
||||||
RedmineExtensions::PatchManager.register_model_patch 'Mailer', 'RedmineCustomWorkflows::Patches::Models::MailerPatch'
|
RedmineExtensions::PatchManager.register_model_patch 'Mailer', 'RedmineCustomWorkflows::Patches::Models::MailerPatch'
|
||||||
else
|
else
|
||||||
Mailer.prepend RedmineCustomWorkflows::Patches::Models::MailerPatch
|
Mailer.prepend RedmineCustomWorkflows::Patches::Models::MailerPatch
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,11 +22,8 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Patches
|
module Patches
|
||||||
module Models
|
module Models
|
||||||
|
# Project model patch
|
||||||
module ProjectPatch
|
module ProjectPatch
|
||||||
|
|
||||||
attr_accessor 'custom_workflow_messages'
|
|
||||||
attr_accessor 'custom_workflow_env'
|
|
||||||
|
|
||||||
def custom_workflow_messages
|
def custom_workflow_messages
|
||||||
@custom_workflow_messages ||= {}
|
@custom_workflow_messages ||= {}
|
||||||
end
|
end
|
||||||
@ -39,8 +35,11 @@ module RedmineCustomWorkflows
|
|||||||
def self.prepended(base)
|
def self.prepended(base)
|
||||||
base.class_eval do
|
base.class_eval do
|
||||||
has_and_belongs_to_many :custom_workflows
|
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) }
|
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
|
before_save :before_save_custom_workflows
|
||||||
after_save :after_save_custom_workflows
|
after_save :after_save_custom_workflows
|
||||||
@ -54,8 +53,10 @@ module RedmineCustomWorkflows
|
|||||||
CustomWorkflow.run_custom_workflows(:project_attachments, project, event)
|
CustomWorkflow.run_custom_workflows(:project_attachments, project, event)
|
||||||
end
|
end
|
||||||
|
|
||||||
[:before_add, :before_remove, :after_add, :after_remove].each do |observable|
|
%i[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) }
|
send("#{observable}_for_attachments") << lambda { |event, project, attachment|
|
||||||
|
Project.attachments_callback event, project, attachment
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -66,6 +67,7 @@ module RedmineCustomWorkflows
|
|||||||
CustomWorkflow.run_shared_code self
|
CustomWorkflow.run_shared_code self
|
||||||
CustomWorkflow.run_custom_workflows :project, self, :before_save
|
CustomWorkflow.run_custom_workflows :project, self, :before_save
|
||||||
throw :abort if errors.any?
|
throw :abort if errors.any?
|
||||||
|
|
||||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||||
ensure
|
ensure
|
||||||
@saved_attributes = nil
|
@saved_attributes = nil
|
||||||
@ -77,23 +79,21 @@ module RedmineCustomWorkflows
|
|||||||
|
|
||||||
def before_destroy_custom_workflows
|
def before_destroy_custom_workflows
|
||||||
res = CustomWorkflow.run_custom_workflows :project, self, :before_destroy
|
res = CustomWorkflow.run_custom_workflows :project, self, :before_destroy
|
||||||
if res == false
|
throw :abort if res == false
|
||||||
throw :abort
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_destroy_custom_workflows
|
def after_destroy_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :project, self, :after_destroy
|
CustomWorkflow.run_custom_workflows :project, self, :after_destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Apply the patch
|
# Apply the patch
|
||||||
if Redmine::Plugin.installed?(:easy_extensions)
|
if Redmine::Plugin.installed?('easy_extensions')
|
||||||
RedmineExtensions::PatchManager.register_model_patch 'Project', 'RedmineCustomWorkflows::Patches::Models::ProjectPatch'
|
RedmineExtensions::PatchManager.register_model_patch 'Project',
|
||||||
|
'RedmineCustomWorkflows::Patches::Models::ProjectPatch'
|
||||||
else
|
else
|
||||||
Project.prepend RedmineCustomWorkflows::Patches::Models::ProjectPatch
|
Project.prepend RedmineCustomWorkflows::Patches::Models::ProjectPatch
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,11 +22,8 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Patches
|
module Patches
|
||||||
module Models
|
module Models
|
||||||
|
# Time entry model patch
|
||||||
module TimeEntryPatch
|
module TimeEntryPatch
|
||||||
|
|
||||||
attr_accessor 'custom_workflow_messages'
|
|
||||||
attr_accessor 'custom_workflow_env'
|
|
||||||
|
|
||||||
def custom_workflow_messages
|
def custom_workflow_messages
|
||||||
@custom_workflow_messages ||= {}
|
@custom_workflow_messages ||= {}
|
||||||
end
|
end
|
||||||
@ -51,6 +47,7 @@ module RedmineCustomWorkflows
|
|||||||
CustomWorkflow.run_shared_code(self)
|
CustomWorkflow.run_shared_code(self)
|
||||||
CustomWorkflow.run_custom_workflows(:time_entry, self, :before_save)
|
CustomWorkflow.run_custom_workflows(:time_entry, self, :before_save)
|
||||||
throw :abort if errors.any?
|
throw :abort if errors.any?
|
||||||
|
|
||||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||||
ensure
|
ensure
|
||||||
@saved_attributes = nil
|
@saved_attributes = nil
|
||||||
@ -62,24 +59,21 @@ module RedmineCustomWorkflows
|
|||||||
|
|
||||||
def before_destroy_custom_workflows
|
def before_destroy_custom_workflows
|
||||||
res = CustomWorkflow.run_custom_workflows :time_entry, self, :before_destroy
|
res = CustomWorkflow.run_custom_workflows :time_entry, self, :before_destroy
|
||||||
if res == false
|
throw :abort if res == false
|
||||||
throw :abort
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_destroy_custom_workflows
|
def after_destroy_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :time_entry, self, :after_destroy
|
CustomWorkflow.run_custom_workflows :time_entry, self, :after_destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Apply the patch
|
# Apply the patch
|
||||||
if Redmine::Plugin.installed?(:easy_extensions)
|
if Redmine::Plugin.installed?('easy_extensions')
|
||||||
RedmineExtensions::PatchManager.register_model_patch 'TimeEntry',
|
RedmineExtensions::PatchManager.register_model_patch 'TimeEntry',
|
||||||
'RedmineCustomWorkflows::Patches::Models::TimeEntryPatch'
|
'RedmineCustomWorkflows::Patches::Models::TimeEntryPatch'
|
||||||
else
|
else
|
||||||
TimeEntry.prepend RedmineCustomWorkflows::Patches::Models::TimeEntryPatch
|
TimeEntry.prepend RedmineCustomWorkflows::Patches::Models::TimeEntryPatch
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,11 +22,8 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Patches
|
module Patches
|
||||||
module Models
|
module Models
|
||||||
|
# User model patch
|
||||||
module UserPatch
|
module UserPatch
|
||||||
|
|
||||||
attr_accessor 'custom_workflow_messages'
|
|
||||||
attr_accessor 'custom_workflow_env'
|
|
||||||
|
|
||||||
def custom_workflow_messages
|
def custom_workflow_messages
|
||||||
@custom_workflow_messages ||= {}
|
@custom_workflow_messages ||= {}
|
||||||
end
|
end
|
||||||
@ -51,6 +47,7 @@ module RedmineCustomWorkflows
|
|||||||
CustomWorkflow.run_shared_code self
|
CustomWorkflow.run_shared_code self
|
||||||
CustomWorkflow.run_custom_workflows :user, self, :before_save
|
CustomWorkflow.run_custom_workflows :user, self, :before_save
|
||||||
throw :abort if errors.any?
|
throw :abort if errors.any?
|
||||||
|
|
||||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||||
ensure
|
ensure
|
||||||
@saved_attributes = nil
|
@saved_attributes = nil
|
||||||
@ -62,22 +59,19 @@ module RedmineCustomWorkflows
|
|||||||
|
|
||||||
def before_destroy_custom_workflows
|
def before_destroy_custom_workflows
|
||||||
res = CustomWorkflow.run_custom_workflows :user, self, :before_destroy
|
res = CustomWorkflow.run_custom_workflows :user, self, :before_destroy
|
||||||
if res == false
|
throw :abort if res == false
|
||||||
throw :abort
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_destroy_custom_workflows
|
def after_destroy_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :user, self, :after_destroy
|
CustomWorkflow.run_custom_workflows :user, self, :after_destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Apply the patch
|
# Apply the patch
|
||||||
if Redmine::Plugin.installed?(:easy_extensions)
|
if Redmine::Plugin.installed?('easy_extensions')
|
||||||
RedmineExtensions::PatchManager.register_model_patch 'User', 'RedmineCustomWorkflows::Patches::Models::UserPatch'
|
RedmineExtensions::PatchManager.register_model_patch 'User', 'RedmineCustomWorkflows::Patches::Models::UserPatch'
|
||||||
else
|
else
|
||||||
User.prepend RedmineCustomWorkflows::Patches::Models::UserPatch
|
User.prepend RedmineCustomWorkflows::Patches::Models::UserPatch
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,11 +22,8 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Patches
|
module Patches
|
||||||
module Models
|
module Models
|
||||||
|
# Version model patch
|
||||||
module VersionPatch
|
module VersionPatch
|
||||||
|
|
||||||
attr_accessor 'custom_workflow_messages'
|
|
||||||
attr_accessor 'custom_workflow_env'
|
|
||||||
|
|
||||||
def custom_workflow_messages
|
def custom_workflow_messages
|
||||||
@custom_workflow_messages ||= {}
|
@custom_workflow_messages ||= {}
|
||||||
end
|
end
|
||||||
@ -51,6 +47,7 @@ module RedmineCustomWorkflows
|
|||||||
CustomWorkflow.run_shared_code self
|
CustomWorkflow.run_shared_code self
|
||||||
CustomWorkflow.run_custom_workflows :version, self, :before_save
|
CustomWorkflow.run_custom_workflows :version, self, :before_save
|
||||||
throw :abort if errors.any?
|
throw :abort if errors.any?
|
||||||
|
|
||||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||||
ensure
|
ensure
|
||||||
@saved_attributes = nil
|
@saved_attributes = nil
|
||||||
@ -62,23 +59,21 @@ module RedmineCustomWorkflows
|
|||||||
|
|
||||||
def before_destroy_custom_workflows
|
def before_destroy_custom_workflows
|
||||||
res = CustomWorkflow.run_custom_workflows :version, self, :before_destroy
|
res = CustomWorkflow.run_custom_workflows :version, self, :before_destroy
|
||||||
if res == false
|
throw :abort if res == false
|
||||||
throw :abort
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_destroy_custom_workflows
|
def after_destroy_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :version, self, :after_destroy
|
CustomWorkflow.run_custom_workflows :version, self, :after_destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Apply the patch
|
# Apply the patch
|
||||||
if Redmine::Plugin.installed?(:easy_extensions)
|
if Redmine::Plugin.installed?('easy_extensions')
|
||||||
RedmineExtensions::PatchManager.register_model_patch 'Version', 'RedmineCustomWorkflows::Patches::Models::VersionPatch'
|
RedmineExtensions::PatchManager.register_model_patch 'Version',
|
||||||
|
'RedmineCustomWorkflows::Patches::Models::VersionPatch'
|
||||||
else
|
else
|
||||||
Version.prepend RedmineCustomWorkflows::Patches::Models::VersionPatch
|
Version.prepend RedmineCustomWorkflows::Patches::Models::VersionPatch
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,11 +22,8 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Patches
|
module Patches
|
||||||
module Models
|
module Models
|
||||||
|
# Wiki content model patch
|
||||||
module WikiContentPatch
|
module WikiContentPatch
|
||||||
|
|
||||||
attr_accessor 'custom_workflow_messages'
|
|
||||||
attr_accessor 'custom_workflow_env'
|
|
||||||
|
|
||||||
def custom_workflow_messages
|
def custom_workflow_messages
|
||||||
@custom_workflow_messages ||= {}
|
@custom_workflow_messages ||= {}
|
||||||
end
|
end
|
||||||
@ -51,6 +47,7 @@ module RedmineCustomWorkflows
|
|||||||
CustomWorkflow.run_shared_code self
|
CustomWorkflow.run_shared_code self
|
||||||
CustomWorkflow.run_custom_workflows :wiki_content, self, :before_save
|
CustomWorkflow.run_custom_workflows :wiki_content, self, :before_save
|
||||||
throw :abort if errors.any?
|
throw :abort if errors.any?
|
||||||
|
|
||||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||||
ensure
|
ensure
|
||||||
@saved_attributes = nil
|
@saved_attributes = nil
|
||||||
@ -62,24 +59,21 @@ module RedmineCustomWorkflows
|
|||||||
|
|
||||||
def before_destroy_custom_workflows
|
def before_destroy_custom_workflows
|
||||||
res = CustomWorkflow.run_custom_workflows :wiki_content, self, :before_destroy
|
res = CustomWorkflow.run_custom_workflows :wiki_content, self, :before_destroy
|
||||||
if res == false
|
throw :abort if res == false
|
||||||
throw :abort
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_destroy_custom_workflows
|
def after_destroy_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :wiki_content, self, :after_destroy
|
CustomWorkflow.run_custom_workflows :wiki_content, self, :after_destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Apply the patch
|
# Apply the patch
|
||||||
if Redmine::Plugin.installed?(:easy_extensions)
|
if Redmine::Plugin.installed?('easy_extensions')
|
||||||
RedmineExtensions::PatchManager.register_model_patch 'WikiContent',
|
RedmineExtensions::PatchManager.register_model_patch 'WikiContent',
|
||||||
'RedmineCustomWorkflows::Patches::Models::WikiContentPatch'
|
'RedmineCustomWorkflows::Patches::Models::WikiContentPatch'
|
||||||
else
|
else
|
||||||
WikiContent.prepend RedmineCustomWorkflows::Patches::Models::WikiContentPatch
|
WikiContent.prepend RedmineCustomWorkflows::Patches::Models::WikiContentPatch
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -23,11 +22,8 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Patches
|
module Patches
|
||||||
module Models
|
module Models
|
||||||
|
# Wiki page model patch
|
||||||
module WikiPagePatch
|
module WikiPagePatch
|
||||||
|
|
||||||
attr_accessor 'custom_workflow_messages'
|
|
||||||
attr_accessor 'custom_workflow_env'
|
|
||||||
|
|
||||||
def custom_workflow_messages
|
def custom_workflow_messages
|
||||||
@custom_workflow_messages ||= {}
|
@custom_workflow_messages ||= {}
|
||||||
end
|
end
|
||||||
@ -45,21 +41,22 @@ module RedmineCustomWorkflows
|
|||||||
CustomWorkflow.run_custom_workflows :wiki_page_attachments, page, event
|
CustomWorkflow.run_custom_workflows :wiki_page_attachments, page, event
|
||||||
end
|
end
|
||||||
|
|
||||||
[:before_add, :before_remove, :after_add, :after_remove].each do |observable|
|
%i[before_add before_remove after_add after_remove].each do |observable|
|
||||||
send("#{observable}_for_attachments") << lambda { |event, page, attachment| WikiPage.attachments_callback(event, page, attachment) }
|
send("#{observable}_for_attachments") << lambda { |event, page, attachment|
|
||||||
|
WikiPage.attachments_callback(event, page, attachment)
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Apply the patch
|
# Apply the patch
|
||||||
if Redmine::Plugin.installed?(:easy_extensions)
|
if Redmine::Plugin.installed?('easy_extensions')
|
||||||
RedmineExtensions::PatchManager.register_model_patch 'WikiPage',
|
RedmineExtensions::PatchManager.register_model_patch 'WikiPage',
|
||||||
'RedmineCustomWorkflows::Patches::Models::WikiPagePatch'
|
'RedmineCustomWorkflows::Patches::Models::WikiPagePatch'
|
||||||
else
|
else
|
||||||
WikiPage.prepend RedmineCustomWorkflows::Patches::Models::WikiPagePatch
|
WikiPage.prepend RedmineCustomWorkflows::Patches::Models::WikiPagePatch
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Document Management System "Features"
|
# Redmine plugin for Document Management System "Features"
|
||||||
@ -19,10 +18,10 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# Attachment controller patch test
|
||||||
class AttachmentsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
class AttachmentsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||||
|
|
||||||
fixtures :attachments, :enabled_modules, :custom_workflows, :custom_workflows_projects,
|
fixtures :attachments, :enabled_modules, :custom_workflows, :custom_workflows_projects,
|
||||||
:roles, :members, :member_roles
|
:roles, :members, :member_roles
|
||||||
|
|
||||||
@ -44,5 +43,4 @@ class AttachmentsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
|||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_equal request.remote_ip, @controller.flash[:warning]
|
assert_equal request.remote_ip, @controller.flash[:warning]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -20,10 +19,10 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# Custom workflows controller test
|
||||||
class CustomWorkflowsControllerTest < RedmineCustomWorkflows::Test::TestCase
|
class CustomWorkflowsControllerTest < RedmineCustomWorkflows::Test::TestCase
|
||||||
|
|
||||||
fixtures :custom_workflows
|
fixtures :custom_workflows
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@ -47,5 +46,4 @@ class CustomWorkflowsControllerTest < RedmineCustomWorkflows::Test::TestCase
|
|||||||
get :index
|
get :index
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Document Management System "Features"
|
# Redmine plugin for Document Management System "Features"
|
||||||
@ -19,11 +18,11 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# Group controller patch test
|
||||||
class GroupControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
class GroupControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||||
include Rails.application.routes.url_helpers
|
include Rails.application.routes.url_helpers
|
||||||
|
|
||||||
fixtures :custom_workflows, :custom_workflows_projects
|
fixtures :custom_workflows, :custom_workflows_projects
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@ -41,11 +40,10 @@ class GroupControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
|||||||
assert_equal 'Custom workflow', @controller.flash[:notice]
|
assert_equal 'Custom workflow', @controller.flash[:notice]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_cw_env
|
# def test_cw_env
|
||||||
@request.headers['Referer'] = edit_group_path(id: @group10.id)
|
# @request.headers['Referer'] = edit_group_path(id: @group10.id)
|
||||||
put :update, params: { id: @group10.id, group: { name: 'Updated name' } }
|
# put :update, params: { id: @group10.id, group: { name: 'Updated name' } }
|
||||||
assert_redirected_to edit_group_path(id: @group10.id)
|
# assert_redirected_to edit_group_path(id: @group10.id)
|
||||||
assert_equal request.remote_ip, @controller.flash[:warning]
|
# assert_equal request.remote_ip, @controller.flash[:warning]
|
||||||
end
|
# end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Document Management System "Features"
|
# Redmine plugin for Document Management System "Features"
|
||||||
@ -19,10 +18,10 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# Issue relation controller patch test
|
||||||
class IssueRelationsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
class IssueRelationsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||||
|
|
||||||
fixtures :user_preferences, :issues, :versions, :trackers, :projects_trackers, :issue_statuses,
|
fixtures :user_preferences, :issues, :versions, :trackers, :projects_trackers, :issue_statuses,
|
||||||
:enabled_modules, :enumerations, :issue_categories, :custom_workflows, :custom_workflows_projects,
|
:enabled_modules, :enumerations, :issue_categories, :custom_workflows, :custom_workflows_projects,
|
||||||
:issue_relations, :roles, :members, :member_roles, :attachments
|
:issue_relations, :roles, :members, :member_roles, :attachments
|
||||||
@ -45,5 +44,4 @@ class IssueRelationsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
|||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_equal request.remote_ip, @controller.flash[:warning]
|
assert_equal request.remote_ip, @controller.flash[:warning]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Document Management System "Features"
|
# Redmine plugin for Document Management System "Features"
|
||||||
@ -19,13 +18,13 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# Issue controller patch test
|
||||||
class IssuesControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
class IssuesControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||||
|
|
||||||
fixtures :user_preferences, :issues, :versions, :trackers, :projects_trackers, :issue_statuses,
|
fixtures :user_preferences, :issues, :versions, :trackers, :projects_trackers, :issue_statuses,
|
||||||
:enabled_modules, :enumerations, :issue_categories, :custom_workflows, :custom_workflows_projects, :roles, :members,
|
:enabled_modules, :enumerations, :issue_categories, :custom_workflows, :custom_workflows_projects, :roles,
|
||||||
:member_roles
|
:members, :member_roles
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@ -52,5 +51,4 @@ class IssuesControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
|||||||
assert_redirected_to action: 'show', id: @issue1.id
|
assert_redirected_to action: 'show', id: @issue1.id
|
||||||
assert_equal request.remote_ip, @controller.flash[:warning]
|
assert_equal request.remote_ip, @controller.flash[:warning]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Document Management System "Features"
|
# Redmine plugin for Document Management System "Features"
|
||||||
@ -19,10 +18,10 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# Project controller patch test
|
||||||
class ProjectsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
class ProjectsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||||
|
|
||||||
fixtures :user_preferences, :issues, :versions, :trackers, :projects_trackers, :enabled_modules,
|
fixtures :user_preferences, :issues, :versions, :trackers, :projects_trackers, :enabled_modules,
|
||||||
:enumerations, :custom_workflows, :custom_workflows_projects, :roles, :members, :member_roles
|
:enumerations, :custom_workflows, :custom_workflows_projects, :roles, :members, :member_roles
|
||||||
|
|
||||||
@ -43,5 +42,4 @@ class ProjectsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
|||||||
assert_redirected_to settings_project_path(@project1)
|
assert_redirected_to settings_project_path(@project1)
|
||||||
assert_equal request.remote_ip, @controller.flash[:warning]
|
assert_equal request.remote_ip, @controller.flash[:warning]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Document Management System "Features"
|
# Redmine plugin for Document Management System "Features"
|
||||||
@ -19,10 +18,10 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# Time controller patch test
|
||||||
class TimelogControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
class TimelogControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||||
|
|
||||||
fixtures :user_preferences, :issues, :versions, :trackers, :projects_trackers, :issue_statuses,
|
fixtures :user_preferences, :issues, :versions, :trackers, :projects_trackers, :issue_statuses,
|
||||||
:enabled_modules, :enumerations, :issue_categories, :custom_workflows, :custom_workflows_projects,
|
:enabled_modules, :enumerations, :issue_categories, :custom_workflows, :custom_workflows_projects,
|
||||||
:time_entries, :roles, :members, :member_roles
|
:time_entries, :roles, :members, :member_roles
|
||||||
@ -45,5 +44,4 @@ class TimelogControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
|||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_equal request.remote_ip, @controller.flash[:warning]
|
assert_equal request.remote_ip, @controller.flash[:warning]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Document Management System "Features"
|
# Redmine plugin for Document Management System "Features"
|
||||||
@ -19,10 +18,10 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# Users controller patch test
|
||||||
class UsersControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
class UsersControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||||
|
|
||||||
fixtures :custom_workflows, :custom_workflows_projects
|
fixtures :custom_workflows, :custom_workflows_projects
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@ -32,15 +31,14 @@ class UsersControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_update_with_cw
|
def test_update_with_cw
|
||||||
put :update, params: { id: @jsmith.id, user: { lastname: 'updated_lastname' }}
|
put :update, params: { id: @jsmith.id, user: { lastname: 'updated_lastname' } }
|
||||||
assert_redirected_to edit_user_path(id: @jsmith.id)
|
assert_redirected_to edit_user_path(id: @jsmith.id)
|
||||||
assert_equal 'Custom workflow', @controller.flash[:notice]
|
assert_equal 'Custom workflow', @controller.flash[:notice]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_cw_env
|
def test_cw_env
|
||||||
put :update, params: { id: @jsmith.id, user: { lastname: 'updated_lastname' }}
|
put :update, params: { id: @jsmith.id, user: { lastname: 'updated_lastname' } }
|
||||||
assert_redirected_to edit_user_path(id: @jsmith.id)
|
assert_redirected_to edit_user_path(id: @jsmith.id)
|
||||||
assert_equal request.remote_ip, @controller.flash[:warning]
|
assert_equal request.remote_ip, @controller.flash[:warning]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Document Management System "Features"
|
# Redmine plugin for Document Management System "Features"
|
||||||
@ -19,10 +18,10 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# Version controller patch test
|
||||||
class VersionsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
class VersionsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||||
|
|
||||||
fixtures :versions, :custom_workflows, :custom_workflows_projects, :roles, :members, :member_roles
|
fixtures :versions, :custom_workflows, :custom_workflows_projects, :roles, :members, :member_roles
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@ -43,5 +42,4 @@ class VersionsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
|||||||
assert_redirected_to settings_project_path(id: @project1, tab: 'versions')
|
assert_redirected_to settings_project_path(id: @project1, tab: 'versions')
|
||||||
assert_equal request.remote_ip, @controller.flash[:warning]
|
assert_equal request.remote_ip, @controller.flash[:warning]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Document Management System "Features"
|
# Redmine plugin for Document Management System "Features"
|
||||||
@ -19,10 +18,10 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# Wiki controller patch test
|
||||||
class WikiControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
class WikiControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||||
|
|
||||||
fixtures :user_preferences, :issues, :versions, :trackers, :projects_trackers, :enabled_modules,
|
fixtures :user_preferences, :issues, :versions, :trackers, :projects_trackers, :enabled_modules,
|
||||||
:enumerations, :wikis, :wiki_pages, :wiki_contents, :custom_workflows, :custom_workflows_projects,
|
:enumerations, :wikis, :wiki_pages, :wiki_contents, :custom_workflows, :custom_workflows_projects,
|
||||||
:roles, :members, :member_roles
|
:roles, :members, :member_roles
|
||||||
@ -35,10 +34,13 @@ class WikiControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_update_with_cw
|
def test_update_with_cw
|
||||||
put :update, params: { project_id: @project1.id, id: 'Another_page',
|
put :update,
|
||||||
content: { comments: 'my comments', text: 'edited', version: 1 } }
|
params: {
|
||||||
|
project_id: @project1.id,
|
||||||
|
id: 'Another_page',
|
||||||
|
content: { comments: 'my comments', text: 'edited', version: 1 }
|
||||||
|
}
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_equal 'Custom workflow', @controller.flash[:notice]
|
assert_equal 'Custom workflow', @controller.flash[:notice]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -22,10 +21,9 @@
|
|||||||
|
|
||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Test
|
module Test
|
||||||
|
# Test case base class
|
||||||
class TestCase < ActionController::TestCase
|
class TestCase < ActionController::TestCase
|
||||||
|
fixtures :users, :email_addresses, :projects
|
||||||
self.fixtures :users, :email_addresses, :projects
|
|
||||||
|
|
||||||
# Allow us to override the fixtures method to implement fixtures for our plugin.
|
# Allow us to override the fixtures method to implement fixtures for our plugin.
|
||||||
# Ultimately it allows for better integration without blowing redmine fixtures up,
|
# Ultimately it allows for better integration without blowing redmine fixtures up,
|
||||||
@ -49,8 +47,6 @@ module RedmineCustomWorkflows
|
|||||||
@project1 = Project.find 1
|
@project1 = Project.find 1
|
||||||
User.current = nil
|
User.current = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -20,8 +19,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# Attachment patch test class
|
||||||
class AttachmentPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
class AttachmentPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
fixtures :attachments
|
fixtures :attachments
|
||||||
|
|
||||||
@ -42,5 +42,4 @@ class AttachmentPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
|||||||
@attachment1.custom_workflow_env[:remote_ip] = '127.0.0.1'
|
@attachment1.custom_workflow_env[:remote_ip] = '127.0.0.1'
|
||||||
assert_equal '127.0.0.1', @attachment1.custom_workflow_env[:remote_ip]
|
assert_equal '127.0.0.1', @attachment1.custom_workflow_env[:remote_ip]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -20,11 +19,11 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# Custom mailer test class
|
||||||
class CustomWorkflowMailerTest < RedmineCustomWorkflows::Test::UnitTest
|
class CustomWorkflowMailerTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
include Redmine::I18n
|
include Redmine::I18n
|
||||||
|
|
||||||
fixtures :users, :email_addresses
|
fixtures :users, :email_addresses
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@ -62,5 +61,4 @@ class CustomWorkflowMailerTest < RedmineCustomWorkflows::Test::UnitTest
|
|||||||
def html_part(email)
|
def html_part(email)
|
||||||
email.parts.detect { |part| part.content_type.include?('text/html') }
|
email.parts.detect { |part| part.content_type.include?('text/html') }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -20,8 +19,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# Custom workflow test class
|
||||||
class CustomWorkflowTest < RedmineCustomWorkflows::Test::UnitTest
|
class CustomWorkflowTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
fixtures :projects, :custom_workflows, :custom_workflows_projects
|
fixtures :projects, :custom_workflows, :custom_workflows_projects
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ class CustomWorkflowTest < RedmineCustomWorkflows::Test::UnitTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_import_from_xml
|
def test_import_from_xml
|
||||||
xml = %{
|
xml = %(
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<hash>
|
<hash>
|
||||||
<id type="integer">20</id>
|
<id type="integer">20</id>
|
||||||
@ -65,7 +65,7 @@ class CustomWorkflowTest < RedmineCustomWorkflows::Test::UnitTest
|
|||||||
<ruby-version>3.0.2-p107</ruby-version>
|
<ruby-version>3.0.2-p107</ruby-version>
|
||||||
<rails-version>6.1.6.1</rails-version>
|
<rails-version>6.1.6.1</rails-version>
|
||||||
</hash>
|
</hash>
|
||||||
}
|
)
|
||||||
cw = CustomWorkflow.import_from_xml(xml)
|
cw = CustomWorkflow.import_from_xml(xml)
|
||||||
assert cw
|
assert cw
|
||||||
end
|
end
|
||||||
@ -74,5 +74,4 @@ class CustomWorkflowTest < RedmineCustomWorkflows::Test::UnitTest
|
|||||||
xml = @cw1.export_as_xml
|
xml = @cw1.export_as_xml
|
||||||
assert xml.include?("<name>#{@cw1}</name>")
|
assert xml.include?("<name>#{@cw1}</name>")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -20,8 +19,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# Group patch test class
|
||||||
class GroupPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
class GroupPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
fixtures :users
|
fixtures :users
|
||||||
|
|
||||||
@ -42,5 +42,4 @@ class GroupPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
|||||||
@group10.custom_workflow_env[:remote_ip] = '127.0.0.1'
|
@group10.custom_workflow_env[:remote_ip] = '127.0.0.1'
|
||||||
assert_equal '127.0.0.1', @group10.custom_workflow_env[:remote_ip]
|
assert_equal '127.0.0.1', @group10.custom_workflow_env[:remote_ip]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -20,8 +19,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# Issue patch test class
|
||||||
class IssuePatchTest < RedmineCustomWorkflows::Test::UnitTest
|
class IssuePatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
fixtures :issues
|
fixtures :issues
|
||||||
|
|
||||||
@ -42,5 +42,4 @@ class IssuePatchTest < RedmineCustomWorkflows::Test::UnitTest
|
|||||||
@issue1.custom_workflow_env[:remote_ip] = '127.0.0.1'
|
@issue1.custom_workflow_env[:remote_ip] = '127.0.0.1'
|
||||||
assert_equal '127.0.0.1', @issue1.custom_workflow_env[:remote_ip]
|
assert_equal '127.0.0.1', @issue1.custom_workflow_env[:remote_ip]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -20,8 +19,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# Issue relation patch test class
|
||||||
class IssueRelationPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
class IssueRelationPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
fixtures :issue_relations
|
fixtures :issue_relations
|
||||||
|
|
||||||
@ -42,5 +42,4 @@ class IssueRelationPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
|||||||
@issue_relation1.custom_workflow_env[:remote_ip] = '127.0.0.1'
|
@issue_relation1.custom_workflow_env[:remote_ip] = '127.0.0.1'
|
||||||
assert_equal '127.0.0.1', @issue_relation1.custom_workflow_env[:remote_ip]
|
assert_equal '127.0.0.1', @issue_relation1.custom_workflow_env[:remote_ip]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -20,8 +19,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# Project patch test class
|
||||||
class ProjectPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
class ProjectPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
fixtures :projects
|
fixtures :projects
|
||||||
|
|
||||||
@ -42,5 +42,4 @@ class ProjectPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
|||||||
@project1.custom_workflow_env[:remote_ip] = '127.0.0.1'
|
@project1.custom_workflow_env[:remote_ip] = '127.0.0.1'
|
||||||
assert_equal '127.0.0.1', @project1.custom_workflow_env[:remote_ip]
|
assert_equal '127.0.0.1', @project1.custom_workflow_env[:remote_ip]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -20,8 +19,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# Time entry patch test class
|
||||||
class TimeEntryPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
class TimeEntryPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
fixtures :time_entries
|
fixtures :time_entries
|
||||||
|
|
||||||
@ -42,5 +42,4 @@ class TimeEntryPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
|||||||
@time_entry1.custom_workflow_env[:remote_ip] = '127.0.0.1'
|
@time_entry1.custom_workflow_env[:remote_ip] = '127.0.0.1'
|
||||||
assert_equal '127.0.0.1', @time_entry1.custom_workflow_env[:remote_ip]
|
assert_equal '127.0.0.1', @time_entry1.custom_workflow_env[:remote_ip]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -20,8 +19,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# user patch test class
|
||||||
class UserPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
class UserPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
fixtures :users
|
fixtures :users
|
||||||
|
|
||||||
@ -42,5 +42,4 @@ class UserPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
|||||||
@user1.custom_workflow_env[:remote_ip] = '127.0.0.1'
|
@user1.custom_workflow_env[:remote_ip] = '127.0.0.1'
|
||||||
assert_equal '127.0.0.1', @user1.custom_workflow_env[:remote_ip]
|
assert_equal '127.0.0.1', @user1.custom_workflow_env[:remote_ip]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -20,8 +19,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# Version patch test class
|
||||||
class VersionPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
class VersionPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
fixtures :versions
|
fixtures :versions
|
||||||
|
|
||||||
@ -42,5 +42,4 @@ class VersionPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
|||||||
@version1.custom_workflow_env[:remote_ip] = '127.0.0.1'
|
@version1.custom_workflow_env[:remote_ip] = '127.0.0.1'
|
||||||
assert_equal '127.0.0.1', @version1.custom_workflow_env[:remote_ip]
|
assert_equal '127.0.0.1', @version1.custom_workflow_env[:remote_ip]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -20,8 +19,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# Wiki content patch test class
|
||||||
class WikiContentPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
class WikiContentPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
fixtures :wiki_contents
|
fixtures :wiki_contents
|
||||||
|
|
||||||
@ -42,5 +42,4 @@ class WikiContentPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
|||||||
@wiki_content1.custom_workflow_env[:remote_ip] = '127.0.0.1'
|
@wiki_content1.custom_workflow_env[:remote_ip] = '127.0.0.1'
|
||||||
assert_equal '127.0.0.1', @wiki_content1.custom_workflow_env[:remote_ip]
|
assert_equal '127.0.0.1', @wiki_content1.custom_workflow_env[:remote_ip]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -20,8 +19,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../test_helper', __dir__)
|
||||||
|
|
||||||
|
# Wiki page test class
|
||||||
class WikiPagePatchTest < RedmineCustomWorkflows::Test::UnitTest
|
class WikiPagePatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
fixtures :wiki_pages
|
fixtures :wiki_pages
|
||||||
|
|
||||||
@ -42,5 +42,4 @@ class WikiPagePatchTest < RedmineCustomWorkflows::Test::UnitTest
|
|||||||
@wiki_page1.custom_workflow_env[:remote_ip] = '127.0.0.1'
|
@wiki_page1.custom_workflow_env[:remote_ip] = '127.0.0.1'
|
||||||
assert_equal '127.0.0.1', @wiki_page1.custom_workflow_env[:remote_ip]
|
assert_equal '127.0.0.1', @wiki_page1.custom_workflow_env[:remote_ip]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1,4 +1,3 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# Redmine plugin for Custom Workflows
|
# Redmine plugin for Custom Workflows
|
||||||
@ -22,20 +21,18 @@
|
|||||||
|
|
||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Test
|
module Test
|
||||||
|
# Unit test base class
|
||||||
class UnitTest < ActiveSupport::TestCase
|
class UnitTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# Allow us to override the fixtures method to implement fixtures for our plugin.
|
# Allow us to override the fixtures method to implement fixtures for our plugin.
|
||||||
# Ultimately it allows for better integration without blowing redmine fixtures up,
|
# Ultimately it allows for better integration without blowing redmine fixtures up,
|
||||||
# and allowing us to suppliment redmine fixtures if we need to.
|
# and allowing us to suppliment redmine fixtures if we need to.
|
||||||
def self.fixtures(*table_names)
|
def self.fixtures(*table_names)
|
||||||
dir = File.join( File.dirname(__FILE__), '/fixtures')
|
dir = File.join(File.dirname(__FILE__), '/fixtures')
|
||||||
table_names.each do |x|
|
table_names.each do |x|
|
||||||
ActiveRecord::FixtureSet.create_fixtures(dir, x) if File.exist?("#{dir}/#{x}.yml")
|
ActiveRecord::FixtureSet.create_fixtures(dir, x) if File.exist?("#{dir}/#{x}.yml")
|
||||||
end
|
end
|
||||||
super(table_names)
|
super(table_names)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user