#116 raise errors

This commit is contained in:
Karel Pičman 2019-02-25 14:52:24 +01:00
parent 7507f23ada
commit 15be1cac7e
9 changed files with 9 additions and 1 deletions

View File

@ -116,7 +116,7 @@ class CustomWorkflow < ActiveRecord::Base
object.instance_eval(read_attribute(event)) if respond_to?(event) && read_attribute(event)
rescue WorkflowError => _
rescue Exception => e
errors.add event, :invalid_script, :errors => e
errors.add event, :invalid_script, error: e
end
def validate_scripts_presence

View File

@ -40,6 +40,7 @@ module RedmineCustomWorkflows
@saved_attributes = attributes.dup
CustomWorkflow.run_shared_code(self)
CustomWorkflow.run_custom_workflows(:attachment, self, :before_save)
throw :abort if errors.any?
errors.empty? && (@saved_attributes == attributes || valid?)
ensure
@saved_attributes = nil

View File

@ -54,6 +54,7 @@ module RedmineCustomWorkflows
@saved_attributes = attributes.dup
CustomWorkflow.run_shared_code(self)
CustomWorkflow.run_custom_workflows(:group, self, :before_save)
throw :abort if errors.any?
errors.empty? && (@saved_attributes == attributes || valid?)
ensure
@saved_attributes = nil

View File

@ -68,6 +68,7 @@ module RedmineCustomWorkflows
@saved_attributes = attributes.dup
CustomWorkflow.run_shared_code(self)
CustomWorkflow.run_custom_workflows(:issue, self, :before_save)
throw :abort if errors.any?
errors.empty? && (@saved_attributes == attributes || valid?)
ensure
@saved_attributes = nil

View File

@ -59,6 +59,7 @@ module RedmineCustomWorkflows
@saved_attributes = attributes.dup
CustomWorkflow.run_shared_code(self)
CustomWorkflow.run_custom_workflows(:project, self, :before_save)
throw :abort if errors.any?
errors.empty? && (@saved_attributes == attributes || valid?)
ensure
@saved_attributes = nil

View File

@ -40,6 +40,7 @@ module RedmineCustomWorkflows
@saved_attributes = attributes.dup
CustomWorkflow.run_shared_code(self)
CustomWorkflow.run_custom_workflows(:time_entry, self, :before_save)
throw :abort if errors.any?
errors.empty? && (@saved_attributes == attributes || valid?)
ensure
@saved_attributes = nil

View File

@ -40,6 +40,7 @@ module RedmineCustomWorkflows
@saved_attributes = attributes.dup
CustomWorkflow.run_shared_code(self)
CustomWorkflow.run_custom_workflows(:user, self, :before_save)
throw :abort if errors.any?
errors.empty? && (@saved_attributes == attributes || valid?)
ensure
@saved_attributes = nil

View File

@ -40,6 +40,7 @@ module RedmineCustomWorkflows
@saved_attributes = attributes.dup
CustomWorkflow.run_shared_code(self)
CustomWorkflow.run_custom_workflows(:version, self, :before_save)
throw :abort if errors.any?
errors.empty? && (@saved_attributes == attributes || valid?)
ensure
@saved_attributes = nil

View File

@ -40,6 +40,7 @@ module RedmineCustomWorkflows
@saved_attributes = attributes.dup
CustomWorkflow.run_shared_code(self)
CustomWorkflow.run_custom_workflows(:wiki_content, self, :before_save)
throw :abort if errors.any?
errors.empty? && (@saved_attributes == attributes || valid?)
ensure
@saved_attributes = nil