When using Before Destruction on issues, no error gets displayed #275

This commit is contained in:
Karel Pičman 2022-09-23 10:04:13 +02:00
parent 492dd4e9ba
commit 607b614c8c
11 changed files with 42 additions and 10 deletions

View File

@ -56,7 +56,10 @@ module RedmineCustomWorkflows
end end
def before_destroy_custom_workflows def before_destroy_custom_workflows
CustomWorkflow.run_custom_workflows :attachment, self, :before_destroy res = CustomWorkflow.run_custom_workflows :attachment, self, :before_destroy
if res == false
throw :abort
end
end end
def after_destroy_custom_workflows def after_destroy_custom_workflows

View File

@ -70,7 +70,10 @@ module RedmineCustomWorkflows
end end
def before_destroy_custom_workflows def before_destroy_custom_workflows
CustomWorkflow.run_custom_workflows :group, self, :before_destroy res = CustomWorkflow.run_custom_workflows :group, self, :before_destroy
if res == false
throw :abort
end
end end
def after_destroy_custom_workflows def after_destroy_custom_workflows

View File

@ -84,7 +84,7 @@ 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 if res == false
throw :abort throw :abort
end end
end end

View File

@ -77,7 +77,10 @@ module RedmineCustomWorkflows
end end
def before_destroy_custom_workflows def before_destroy_custom_workflows
CustomWorkflow.run_custom_workflows :issue_relation, self, :before_destroy res = CustomWorkflow.run_custom_workflows :issue_relation, self, :before_destroy
if res == false
throw :abort
end
end end
def after_destroy_custom_workflows def after_destroy_custom_workflows

View File

@ -71,7 +71,10 @@ module RedmineCustomWorkflows
end end
def before_destroy_custom_workflows def before_destroy_custom_workflows
CustomWorkflow.run_custom_workflows :project, self, :before_destroy res = CustomWorkflow.run_custom_workflows :project, self, :before_destroy
if res == false
throw :abort
end
end end
def after_destroy_custom_workflows def after_destroy_custom_workflows

View File

@ -56,7 +56,10 @@ module RedmineCustomWorkflows
end end
def before_destroy_custom_workflows def before_destroy_custom_workflows
CustomWorkflow.run_custom_workflows :time_entry, self, :before_destroy res = CustomWorkflow.run_custom_workflows :time_entry, self, :before_destroy
if res == false
throw :abort
end
end end
def after_destroy_custom_workflows def after_destroy_custom_workflows

View File

@ -56,7 +56,10 @@ module RedmineCustomWorkflows
end end
def before_destroy_custom_workflows def before_destroy_custom_workflows
CustomWorkflow.run_custom_workflows :user, self, :before_destroy res = CustomWorkflow.run_custom_workflows :user, self, :before_destroy
if res == false
throw :abort
end
end end
def after_destroy_custom_workflows def after_destroy_custom_workflows

View File

@ -56,7 +56,10 @@ module RedmineCustomWorkflows
end end
def before_destroy_custom_workflows def before_destroy_custom_workflows
CustomWorkflow.run_custom_workflows :version, self, :before_destroy res = CustomWorkflow.run_custom_workflows :version, self, :before_destroy
if res == false
throw :abort
end
end end
def after_destroy_custom_workflows def after_destroy_custom_workflows

View File

@ -56,7 +56,10 @@ module RedmineCustomWorkflows
end end
def before_destroy_custom_workflows def before_destroy_custom_workflows
CustomWorkflow.run_custom_workflows :wiki_content, self, :before_destroy res = CustomWorkflow.run_custom_workflows :wiki_content, self, :before_destroy
if res == false
throw :abort
end
end end
def after_destroy_custom_workflows def after_destroy_custom_workflows

View File

@ -17,7 +17,8 @@ custom_workflows_001:
after_add: NULL after_add: NULL
before_remove: NULL before_remove: NULL
after_remove: NULL after_remove: NULL
before_destroy: '' before_destroy: "self.custom_workflow_messages[:error] = 'Issue cannot be deleted'\n
return false"
after_destroy : '' after_destroy : ''
custom_workflows_002: custom_workflows_002:

View File

@ -40,4 +40,11 @@ class IssuesControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
assert_equal 'Custom workflow', @controller.flash[:notice] assert_equal 'Custom workflow', @controller.flash[:notice]
end end
def test_delete_with_cw
delete :destroy, params: { id: @issue1.id, todo: 'destroy' }
assert_response :redirect
assert_equal 'Issue cannot be deleted', @controller.flash[:error]
assert Issue.find_by(id: @issue1.id)
end
end end