mirror of
https://github.com/anteo/redmine_custom_workflows.git
synced 2026-01-26 00:04:20 +00:00
IssueRelation.to_s is broken #258
This commit is contained in:
parent
841c30d25c
commit
3b19b30648
@ -30,51 +30,53 @@ module RedmineCustomWorkflows
|
|||||||
after_save :after_save_custom_workflows
|
after_save :after_save_custom_workflows
|
||||||
before_destroy :before_destroy_custom_workflows
|
before_destroy :before_destroy_custom_workflows
|
||||||
after_destroy :after_destroy_custom_workflows
|
after_destroy :after_destroy_custom_workflows
|
||||||
|
end
|
||||||
|
|
||||||
# override IssueRelation.to_s to rescue NoMethodError during CustomWorkflow.validate_syntax due to
|
base.prepend InstanceMethods
|
||||||
# logging of temporarily instatiated IssueRelation with no related issues set
|
|
||||||
alias_method :old_to_s, :to_s
|
|
||||||
|
|
||||||
def to_s(issue=nil)
|
end
|
||||||
if block_given?
|
|
||||||
if Gem.ruby_version < Gem::Version.new('3.0')
|
module InstanceMethods
|
||||||
old_to_s issue, &Proc.new
|
|
||||||
else
|
################################################################################################################
|
||||||
old_to_s issue, &Proc.new {}
|
# Overriden methods
|
||||||
end
|
|
||||||
else
|
# Override IssueRelation.to_s to rescue NoMethodError during CustomWorkflow.validate_syntax due to
|
||||||
old_to_s issue
|
# logging of temporarily instatiated IssueRelation with no related issues set.
|
||||||
end
|
def to_s(issue=nil)
|
||||||
rescue NoMethodError => e
|
super
|
||||||
if issue_from.present? || issue_to.present?
|
rescue NoMethodError => e
|
||||||
raise e
|
if issue_from.present? || issue_to.present?
|
||||||
end
|
raise e
|
||||||
self.class.to_s
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def before_save_custom_workflows
|
################################################################################################################
|
||||||
@issue_relation = self
|
# New methods
|
||||||
@saved_attributes = attributes.dup
|
|
||||||
CustomWorkflow.run_shared_code self
|
|
||||||
CustomWorkflow.run_custom_workflows :issue_relation, self, :before_save
|
|
||||||
throw :abort if errors.any?
|
|
||||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
|
||||||
ensure
|
|
||||||
@saved_attributes = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def after_save_custom_workflows
|
def before_save_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :issue_relation, self, :after_save
|
@issue_relation = self
|
||||||
end
|
@saved_attributes = attributes.dup
|
||||||
|
CustomWorkflow.run_shared_code self
|
||||||
|
CustomWorkflow.run_custom_workflows :issue_relation, self, :before_save
|
||||||
|
throw :abort if errors.any?
|
||||||
|
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||||
|
ensure
|
||||||
|
@saved_attributes = nil
|
||||||
|
end
|
||||||
|
|
||||||
def before_destroy_custom_workflows
|
def after_save_custom_workflows
|
||||||
CustomWorkflow.run_custom_workflows :issue_relation, self, :before_destroy
|
CustomWorkflow.run_custom_workflows :issue_relation, self, :after_save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def before_destroy_custom_workflows
|
||||||
|
CustomWorkflow.run_custom_workflows :issue_relation, self, :before_destroy
|
||||||
|
end
|
||||||
|
|
||||||
|
def after_destroy_custom_workflows
|
||||||
|
CustomWorkflow.run_custom_workflows :issue_relation, self, :after_destroy
|
||||||
|
end
|
||||||
|
|
||||||
def after_destroy_custom_workflows
|
|
||||||
CustomWorkflow.run_custom_workflows :issue_relation, self, :after_destroy
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user