mirror of
https://github.com/anteo/redmine_custom_workflows.git
synced 2026-01-25 15:54:19 +00:00
Rubocop
This commit is contained in:
parent
036c205b08
commit
7c80f63842
@ -18,15 +18,13 @@
|
|||||||
AllCops:
|
AllCops:
|
||||||
TargetRubyVersion: 3.2
|
TargetRubyVersion: 3.2
|
||||||
TargetRailsVersion: 7.1
|
TargetRailsVersion: 7.1
|
||||||
|
SuggestExtensions: false
|
||||||
|
|
||||||
NewCops: enable
|
NewCops: enable
|
||||||
|
|
||||||
Exclude:
|
Exclude:
|
||||||
- '**/vendor/**/*'
|
- '**/vendor/**/*'
|
||||||
|
|
||||||
plugins:
|
|
||||||
- rubocop-performance
|
|
||||||
|
|
||||||
# Rules for CustomWorkflows
|
# Rules for CustomWorkflows
|
||||||
Metrics/BlockLength:
|
Metrics/BlockLength:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|||||||
@ -71,7 +71,7 @@ class CustomWorkflow < ApplicationRecord
|
|||||||
Rails.logger.info "#{str} for #{object.class} (##{object.id}) \"#{object}\""
|
Rails.logger.info "#{str} for #{object.class} (##{object.id}) \"#{object}\""
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.run_shared_code(object)
|
def self.run_shared_code?(object)
|
||||||
# Due to DB migration
|
# Due to DB migration
|
||||||
if CustomWorkflow.table_exists? && CustomWorkflow.active.exists?(observable: :shared)
|
if CustomWorkflow.table_exists? && CustomWorkflow.active.exists?(observable: :shared)
|
||||||
log_message '= Running shared code', object
|
log_message '= Running shared code', object
|
||||||
@ -86,7 +86,7 @@ class CustomWorkflow < ApplicationRecord
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.run_custom_workflows(observable, object, event)
|
def self.run_custom_workflows?(observable, object, event)
|
||||||
if CustomWorkflow.table_exists? # Due to DB migration
|
if CustomWorkflow.table_exists? # Due to DB migration
|
||||||
workflows = CustomWorkflow.active.where(observable: observable)
|
workflows = CustomWorkflow.active.where(observable: observable)
|
||||||
if PROJECT_OBSERVABLES.include? observable
|
if PROJECT_OBSERVABLES.include? observable
|
||||||
@ -153,12 +153,12 @@ class CustomWorkflow < ApplicationRecord
|
|||||||
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
|
||||||
%i[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
|
||||||
@ -180,7 +180,7 @@ class CustomWorkflow < ApplicationRecord
|
|||||||
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
|
||||||
%i[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
|
||||||
|
|||||||
@ -42,8 +42,8 @@ module RedmineCustomWorkflows
|
|||||||
def before_save_custom_workflows
|
def before_save_custom_workflows
|
||||||
@attachment = self
|
@attachment = self
|
||||||
@saved_attributes = attributes.dup
|
@saved_attributes = attributes.dup
|
||||||
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?)
|
||||||
@ -52,16 +52,16 @@ module RedmineCustomWorkflows
|
|||||||
end
|
end
|
||||||
|
|
||||||
def after_save_custom_workflows
|
def after_save_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :attachment, self, :after_save
|
CustomWorkflow.run_custom_workflows? :attachment, self, :after_save
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
||||||
throw :abort if res == false
|
throw :abort if res == false
|
||||||
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
|
||||||
|
|||||||
@ -47,8 +47,8 @@ module RedmineCustomWorkflows
|
|||||||
def self.users_callback(event, group, user)
|
def self.users_callback(event, group, user)
|
||||||
group.instance_variable_set :@group, group
|
group.instance_variable_set :@group, group
|
||||||
group.instance_variable_set :@user, user
|
group.instance_variable_set :@user, user
|
||||||
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
|
||||||
|
|
||||||
%i[before_add before_remove after_add after_remove].each do |observable|
|
%i[before_add before_remove after_add after_remove].each do |observable|
|
||||||
@ -62,8 +62,8 @@ module RedmineCustomWorkflows
|
|||||||
def before_save_custom_workflows
|
def before_save_custom_workflows
|
||||||
@group = self
|
@group = self
|
||||||
@saved_attributes = attributes.dup
|
@saved_attributes = attributes.dup
|
||||||
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?)
|
||||||
@ -72,16 +72,16 @@ module RedmineCustomWorkflows
|
|||||||
end
|
end
|
||||||
|
|
||||||
def after_save_custom_workflows
|
def after_save_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :group, self, :after_save
|
CustomWorkflow.run_custom_workflows? :group, self, :after_save
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
||||||
throw :abort if res == false
|
throw :abort if res == false
|
||||||
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
|
||||||
|
|||||||
@ -46,8 +46,8 @@ module RedmineCustomWorkflows
|
|||||||
def self.attachments_callback(event, issue, attachment)
|
def self.attachments_callback(event, issue, attachment)
|
||||||
issue.instance_variable_set :@issue, issue
|
issue.instance_variable_set :@issue, issue
|
||||||
issue.instance_variable_set :@attachment, attachment
|
issue.instance_variable_set :@attachment, attachment
|
||||||
CustomWorkflow.run_shared_code(issue) if event.to_s.starts_with? 'before_'
|
CustomWorkflow.run_shared_code?(issue) if event.to_s.starts_with? 'before_'
|
||||||
CustomWorkflow.run_custom_workflows :issue_attachments, issue, event
|
CustomWorkflow.run_custom_workflows? :issue_attachments, issue, event
|
||||||
end
|
end
|
||||||
|
|
||||||
%i[before_add before_remove after_add after_remove].each do |observable|
|
%i[before_add before_remove after_add after_remove].each do |observable|
|
||||||
@ -76,8 +76,8 @@ module RedmineCustomWorkflows
|
|||||||
def before_save_custom_workflows
|
def before_save_custom_workflows
|
||||||
@issue = self
|
@issue = self
|
||||||
@saved_attributes = attributes.dup
|
@saved_attributes = attributes.dup
|
||||||
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?)
|
||||||
@ -86,16 +86,16 @@ module RedmineCustomWorkflows
|
|||||||
end
|
end
|
||||||
|
|
||||||
def after_save_custom_workflows
|
def after_save_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :issue, self, :after_save
|
CustomWorkflow.run_custom_workflows? :issue, self, :after_save
|
||||||
end
|
end
|
||||||
|
|
||||||
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)
|
||||||
throw :abort if res == false
|
throw :abort if res == false
|
||||||
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
|
||||||
|
|||||||
@ -60,8 +60,8 @@ module RedmineCustomWorkflows
|
|||||||
def before_save_custom_workflows
|
def before_save_custom_workflows
|
||||||
@issue_relation = self
|
@issue_relation = self
|
||||||
@saved_attributes = attributes.dup
|
@saved_attributes = attributes.dup
|
||||||
CustomWorkflow.run_shared_code self
|
CustomWorkflow.run_shared_code? self
|
||||||
CustomWorkflow.run_custom_workflows :issue_relation, self, :before_save
|
CustomWorkflow.run_custom_workflows? :issue_relation, 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
|
||||||
@ -69,16 +69,16 @@ module RedmineCustomWorkflows
|
|||||||
end
|
end
|
||||||
|
|
||||||
def after_save_custom_workflows
|
def after_save_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :issue_relation, self, :after_save
|
CustomWorkflow.run_custom_workflows? :issue_relation, self, :after_save
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
||||||
throw :abort if res == false
|
throw :abort if res == false
|
||||||
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
|
||||||
|
|||||||
@ -42,8 +42,8 @@ module RedmineCustomWorkflows
|
|||||||
def before_save_custom_workflows
|
def before_save_custom_workflows
|
||||||
@member = self
|
@member = self
|
||||||
@saved_attributes = attributes.dup
|
@saved_attributes = attributes.dup
|
||||||
CustomWorkflow.run_shared_code self
|
CustomWorkflow.run_shared_code? self
|
||||||
CustomWorkflow.run_custom_workflows :member, self, :before_save
|
CustomWorkflow.run_custom_workflows? :member, 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?)
|
||||||
@ -52,16 +52,16 @@ module RedmineCustomWorkflows
|
|||||||
end
|
end
|
||||||
|
|
||||||
def after_save_custom_workflows
|
def after_save_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :member, self, :after_save
|
CustomWorkflow.run_custom_workflows? :member, self, :after_save
|
||||||
end
|
end
|
||||||
|
|
||||||
def before_destroy_custom_workflows
|
def before_destroy_custom_workflows
|
||||||
res = CustomWorkflow.run_custom_workflows :member, self, :before_destroy
|
res = CustomWorkflow.run_custom_workflows? :member, self, :before_destroy
|
||||||
throw :abort if res == false
|
throw :abort if res == false
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_destroy_custom_workflows
|
def after_destroy_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :member, self, :after_destroy
|
CustomWorkflow.run_custom_workflows? :member, self, :after_destroy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -55,8 +55,8 @@ module RedmineCustomWorkflows
|
|||||||
def self.attachments_callback(event, project, attachment)
|
def self.attachments_callback(event, project, attachment)
|
||||||
project.instance_variable_set(:@project, project)
|
project.instance_variable_set(:@project, project)
|
||||||
project.instance_variable_set(:@attachment, attachment)
|
project.instance_variable_set(:@attachment, attachment)
|
||||||
CustomWorkflow.run_shared_code(project) if event.to_s.starts_with? 'before_'
|
CustomWorkflow.run_shared_code?(project) if event.to_s.starts_with? 'before_'
|
||||||
CustomWorkflow.run_custom_workflows(:project_attachments, project, event)
|
CustomWorkflow.run_custom_workflows?(:project_attachments, project, event)
|
||||||
end
|
end
|
||||||
|
|
||||||
%i[before_add before_remove after_add after_remove].each do |observable|
|
%i[before_add before_remove after_add after_remove].each do |observable|
|
||||||
@ -70,8 +70,8 @@ module RedmineCustomWorkflows
|
|||||||
def before_save_custom_workflows
|
def before_save_custom_workflows
|
||||||
@project = self
|
@project = self
|
||||||
@saved_attributes = attributes.dup
|
@saved_attributes = attributes.dup
|
||||||
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?)
|
||||||
@ -80,16 +80,16 @@ module RedmineCustomWorkflows
|
|||||||
end
|
end
|
||||||
|
|
||||||
def after_save_custom_workflows
|
def after_save_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :project, self, :after_save
|
CustomWorkflow.run_custom_workflows? :project, self, :after_save
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
||||||
throw :abort if res == false
|
throw :abort if res == false
|
||||||
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
|
||||||
|
|||||||
@ -42,8 +42,8 @@ module RedmineCustomWorkflows
|
|||||||
def before_save_custom_workflows
|
def before_save_custom_workflows
|
||||||
@time_entry = self
|
@time_entry = self
|
||||||
@saved_attributes = attributes.dup
|
@saved_attributes = attributes.dup
|
||||||
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?)
|
||||||
@ -52,16 +52,16 @@ module RedmineCustomWorkflows
|
|||||||
end
|
end
|
||||||
|
|
||||||
def after_save_custom_workflows
|
def after_save_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :time_entry, self, :after_save
|
CustomWorkflow.run_custom_workflows? :time_entry, self, :after_save
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
||||||
throw :abort if res == false
|
throw :abort if res == false
|
||||||
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
|
||||||
|
|||||||
@ -42,8 +42,8 @@ module RedmineCustomWorkflows
|
|||||||
def before_save_custom_workflows
|
def before_save_custom_workflows
|
||||||
@user = self
|
@user = self
|
||||||
@saved_attributes = attributes.dup
|
@saved_attributes = attributes.dup
|
||||||
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?)
|
||||||
@ -52,16 +52,16 @@ module RedmineCustomWorkflows
|
|||||||
end
|
end
|
||||||
|
|
||||||
def after_save_custom_workflows
|
def after_save_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :user, self, :after_save
|
CustomWorkflow.run_custom_workflows? :user, self, :after_save
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
||||||
throw :abort if res == false
|
throw :abort if res == false
|
||||||
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
|
||||||
|
|||||||
@ -42,8 +42,8 @@ module RedmineCustomWorkflows
|
|||||||
def before_save_custom_workflows
|
def before_save_custom_workflows
|
||||||
@version = self
|
@version = self
|
||||||
@saved_attributes = attributes.dup
|
@saved_attributes = attributes.dup
|
||||||
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?)
|
||||||
@ -52,16 +52,16 @@ module RedmineCustomWorkflows
|
|||||||
end
|
end
|
||||||
|
|
||||||
def after_save_custom_workflows
|
def after_save_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :version, self, :after_save
|
CustomWorkflow.run_custom_workflows? :version, self, :after_save
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
||||||
throw :abort if res == false
|
throw :abort if res == false
|
||||||
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
|
||||||
|
|||||||
@ -42,8 +42,8 @@ module RedmineCustomWorkflows
|
|||||||
def before_save_custom_workflows
|
def before_save_custom_workflows
|
||||||
@content = self
|
@content = self
|
||||||
@saved_attributes = attributes.dup
|
@saved_attributes = attributes.dup
|
||||||
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?)
|
||||||
@ -52,16 +52,16 @@ module RedmineCustomWorkflows
|
|||||||
end
|
end
|
||||||
|
|
||||||
def after_save_custom_workflows
|
def after_save_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :wiki_content, self, :after_save
|
CustomWorkflow.run_custom_workflows? :wiki_content, self, :after_save
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
||||||
throw :abort if res == false
|
throw :abort if res == false
|
||||||
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
|
||||||
|
|||||||
@ -41,8 +41,8 @@ module RedmineCustomWorkflows
|
|||||||
def self.attachments_callback(event, page, attachment)
|
def self.attachments_callback(event, page, attachment)
|
||||||
page.instance_variable_set :@page, page
|
page.instance_variable_set :@page, page
|
||||||
page.instance_variable_set :@attachment, attachment
|
page.instance_variable_set :@attachment, attachment
|
||||||
CustomWorkflow.run_shared_code(page) if event.to_s.starts_with? 'before_'
|
CustomWorkflow.run_shared_code?(page) if event.to_s.starts_with? 'before_'
|
||||||
CustomWorkflow.run_custom_workflows :wiki_page_attachments, page, event
|
CustomWorkflow.run_custom_workflows? :wiki_page_attachments, page, event
|
||||||
end
|
end
|
||||||
|
|
||||||
%i[before_add before_remove after_add after_remove].each do |observable|
|
%i[before_add before_remove after_add after_remove].each do |observable|
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# Attachment controller patch test
|
# Attachment controller patch test
|
||||||
class AttachmentsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
class AttachmentsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@attachment8 = Attachment.find 8
|
@attachment8 = Attachment.find 8
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# Custom workflows controller test
|
# Custom workflows controller test
|
||||||
class CustomWorkflowsControllerTest < RedmineCustomWorkflows::Test::TestCase
|
class CustomWorkflowsControllerTest < RedmineCustomWorkflows::Test::TestCase
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@cw1 = CustomWorkflow.find 1
|
@cw1 = CustomWorkflow.find 1
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# Issue relation controller patch test
|
# Issue relation controller patch test
|
||||||
class IssueRelationsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
class IssueRelationsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@ir1 = IssueRelation.find 1
|
@ir1 = IssueRelation.find 1
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# Issue controller patch test
|
# Issue controller patch test
|
||||||
class IssuesControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
class IssuesControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@issue1 = Issue.find 1
|
@issue1 = Issue.find 1
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# Users controller patch test
|
# Users controller patch test
|
||||||
class MembersControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
class MembersControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@member1 = Member.find 1
|
@member1 = Member.find 1
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# Project controller patch test
|
# Project controller patch test
|
||||||
class ProjectsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
class ProjectsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
post '/login', params: { username: 'jsmith', password: 'jsmith' }
|
post '/login', params: { username: 'jsmith', password: 'jsmith' }
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# Time controller patch test
|
# Time controller patch test
|
||||||
class TimelogControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
class TimelogControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@te1 = TimeEntry.find 1
|
@te1 = TimeEntry.find 1
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# Users controller patch test
|
# Users controller patch test
|
||||||
class UsersControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
class UsersControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
post '/login', params: { username: 'admin', password: 'admin' }
|
post '/login', params: { username: 'admin', password: 'admin' }
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# Version controller patch test
|
# Version controller patch test
|
||||||
class VersionsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
class VersionsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@version1 = Version.find 1
|
@version1 = Version.find 1
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# Wiki controller patch test
|
# Wiki controller patch test
|
||||||
class WikiControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
class WikiControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@wp1 = WikiPage.find 1
|
@wp1 = WikiPage.find 1
|
||||||
|
|||||||
@ -21,9 +21,8 @@ module RedmineCustomWorkflows
|
|||||||
module Test
|
module Test
|
||||||
# Test case base class
|
# Test case base class
|
||||||
class TestCase < ActionDispatch::IntegrationTest
|
class TestCase < ActionDispatch::IntegrationTest
|
||||||
|
|
||||||
def initialize(name)
|
def initialize(name)
|
||||||
super(name)
|
super
|
||||||
# Load all plugin's fixtures
|
# Load all plugin's fixtures
|
||||||
dir = File.join(File.dirname(__FILE__), 'fixtures')
|
dir = File.join(File.dirname(__FILE__), 'fixtures')
|
||||||
ext = '.yml'
|
ext = '.yml'
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# Attachment patch test class
|
# Attachment patch test class
|
||||||
class AttachmentPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
class AttachmentPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@attachment1 = Attachment.find 1
|
@attachment1 = Attachment.find 1
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# Custom workflow test class
|
# Custom workflow test class
|
||||||
class CustomWorkflowTest < RedmineCustomWorkflows::Test::UnitTest
|
class CustomWorkflowTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@cw1 = CustomWorkflow.find 1
|
@cw1 = CustomWorkflow.find 1
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# Group patch test class
|
# Group patch test class
|
||||||
class GroupPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
class GroupPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@group10 = Group.find 10
|
@group10 = Group.find 10
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# Issue patch test class
|
# Issue patch test class
|
||||||
class IssuePatchTest < RedmineCustomWorkflows::Test::UnitTest
|
class IssuePatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@issue1 = Issue.find 1
|
@issue1 = Issue.find 1
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# Issue relation patch test class
|
# Issue relation patch test class
|
||||||
class IssueRelationPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
class IssueRelationPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@issue_relation1 = IssueRelation.find 1
|
@issue_relation1 = IssueRelation.find 1
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# Member patch test class
|
# Member patch test class
|
||||||
class MemberPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
class MemberPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@member1 = Member.find 1
|
@member1 = Member.find 1
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# Project patch test class
|
# Project patch test class
|
||||||
class ProjectPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
class ProjectPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@project1 = Project.find 1
|
@project1 = Project.find 1
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# Time entry patch test class
|
# Time entry patch test class
|
||||||
class TimeEntryPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
class TimeEntryPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@time_entry1 = TimeEntry.find 1
|
@time_entry1 = TimeEntry.find 1
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# User patch test class
|
# User patch test class
|
||||||
class UserPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
class UserPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@user1 = User.find 1
|
@user1 = User.find 1
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# Version patch test class
|
# Version patch test class
|
||||||
class VersionPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
class VersionPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@version1 = Version.find 1
|
@version1 = Version.find 1
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# Wiki content patch test class
|
# Wiki content patch test class
|
||||||
class WikiContentPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
class WikiContentPatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@wiki_content1 = WikiContent.find 1
|
@wiki_content1 = WikiContent.find 1
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# Wiki page test class
|
# Wiki page test class
|
||||||
class WikiPagePatchTest < RedmineCustomWorkflows::Test::UnitTest
|
class WikiPagePatchTest < RedmineCustomWorkflows::Test::UnitTest
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@wiki_page1 = WikiPage.find 1
|
@wiki_page1 = WikiPage.find 1
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,9 +21,8 @@ module RedmineCustomWorkflows
|
|||||||
module Test
|
module Test
|
||||||
# Unit test base class
|
# Unit test base class
|
||||||
class UnitTest < ActiveSupport::TestCase
|
class UnitTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
def initialize(name)
|
def initialize(name)
|
||||||
super(name)
|
super
|
||||||
# Load all plugin's fixtures
|
# Load all plugin's fixtures
|
||||||
dir = File.join(File.dirname(__FILE__), 'fixtures')
|
dir = File.join(File.dirname(__FILE__), 'fixtures')
|
||||||
ext = '.yml'
|
ext = '.yml'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user