From 17f145af564015cf41426e0ad23c24961970ca68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Fri, 3 Jan 2020 08:12:01 +0100 Subject: [PATCH] Redmine 4.1 compatibility --- Gemfile | 2 +- after_init.rb | 1 + app/controllers/custom_workflows_controller.rb | 7 ++++--- app/models/custom_workflow.rb | 7 ++++--- app/models/custom_workflow_mailer.rb | 1 + config/routes.rb | 1 + init.rb | 1 + lib/redmine_custom_workflows.rb | 1 + lib/redmine_custom_workflows/errors/workflow_error.rb | 3 ++- lib/redmine_custom_workflows/hooks/hooks.rb | 1 + lib/redmine_custom_workflows/patches/attachment_patch.rb | 1 + lib/redmine_custom_workflows/patches/group_patch.rb | 1 + lib/redmine_custom_workflows/patches/issue_patch.rb | 1 + lib/redmine_custom_workflows/patches/mailer_patch.rb | 1 + lib/redmine_custom_workflows/patches/project_patch.rb | 1 + .../patches/projects_helper_patch.rb | 1 + lib/redmine_custom_workflows/patches/time_entry_patch.rb | 1 + lib/redmine_custom_workflows/patches/user_patch.rb | 1 + lib/redmine_custom_workflows/patches/version_patch.rb | 1 + lib/redmine_custom_workflows/patches/wiki_content_patch.rb | 1 + lib/redmine_custom_workflows/patches/wiki_page_patch.rb | 1 + lib/redmine_custom_workflows/test/test_case.rb | 1 + lib/redmine_custom_workflows/test/unit_test.rb | 1 + test/ci/redmine_install.sh | 2 +- test/fixtures/custom_workflows.yml | 2 +- test/functional/custom_workflows_controller_test.rb | 1 + test/test_helper.rb | 1 + test/unit/custom_workflow_mailer_test.rb | 1 + test/unit/custom_workflow_test.rb | 1 + test/unit_test.rb | 1 + 30 files changed, 37 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index c63fead..545dbcb 100644 --- a/Gemfile +++ b/Gemfile @@ -26,5 +26,5 @@ gem 'activemodel-serializers-xml' # Redmine extensions unless %w(easyproject easy_gantt).any? { |plugin| Dir.exist?(File.expand_path("../../#{plugin}", __FILE__)) } - gem 'redmine_extensions', '~> 0.2.5' + gem 'redmine_extensions', '~> 0.3.9' end diff --git a/after_init.rb b/after_init.rb index aa87229..969bed5 100644 --- a/after_init.rb +++ b/after_init.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/app/controllers/custom_workflows_controller.rb b/app/controllers/custom_workflows_controller.rb index c9f7c97..a628baf 100644 --- a/app/controllers/custom_workflows_controller.rb +++ b/app/controllers/custom_workflows_controller.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # @@ -50,14 +51,14 @@ class CustomWorkflowsController < ApplicationController end def index - @workflows = CustomWorkflow.includes(:projects).order(:position => :asc) + @workflows = CustomWorkflow.includes(:projects).order(position: :asc) respond_to do |format| format.html end end def export - send_data @workflow.export_as_xml, :filename => @workflow.name + '.xml', :type => :xml + send_data @workflow.export_as_xml, filename: "#{@workflow.name}.xml", type: :xml end def show @@ -87,7 +88,7 @@ class CustomWorkflowsController < ApplicationController else flash[:errors] = @workflow.errors.full_messages.to_sentence end - rescue Exception => e + rescue => e Rails.logger.warn "Workflow import error: #{e.message}\n #{e.backtrace.join("\n ")}" flash[:errors] = l(:error_failed_import) end diff --git a/app/models/custom_workflow.rb b/app/models/custom_workflow.rb index 786d614..0ee17e1 100644 --- a/app/models/custom_workflow.rb +++ b/app/models/custom_workflow.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # @@ -50,7 +51,7 @@ class CustomWorkflow < ActiveRecord::Base end def self.log_message(str, object) - Rails.logger.info str + " for #{object.class} (\##{object.id}) \"#{object}\"" + Rails.logger.info "#{str} for #{object.class} (\##{object.id}) \"#{object}\"" end def self.run_shared_code(object) @@ -96,7 +97,7 @@ class CustomWorkflow < ActiveRecord::Base Rails.logger.info "== User workflow error: #{e.message}" object.errors.add :base, e.error false - rescue Exception => e + rescue => e Rails.logger.error "== Custom workflow exception: #{e.message}\n #{e.backtrace.join("\n ")}" object.errors.add :base, :custom_workflow_error false @@ -109,7 +110,7 @@ class CustomWorkflow < ActiveRecord::Base def validate_syntax_for(object, event) object.instance_eval(read_attribute(event)) if respond_to?(event) && read_attribute(event) rescue WorkflowError => _ - rescue Exception => e + rescue => e errors.add event, :invalid_script, error: e end diff --git a/app/models/custom_workflow_mailer.rb b/app/models/custom_workflow_mailer.rb index 45dc4bb..47457ae 100644 --- a/app/models/custom_workflow_mailer.rb +++ b/app/models/custom_workflow_mailer.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/config/routes.rb b/config/routes.rb index d9207ee..f153eaf 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/init.rb b/init.rb index 54c2126..3a16be8 100644 --- a/init.rb +++ b/init.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/lib/redmine_custom_workflows.rb b/lib/redmine_custom_workflows.rb index 198fed5..f1a2688 100644 --- a/lib/redmine_custom_workflows.rb +++ b/lib/redmine_custom_workflows.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/lib/redmine_custom_workflows/errors/workflow_error.rb b/lib/redmine_custom_workflows/errors/workflow_error.rb index 322f64f..0ac4105 100644 --- a/lib/redmine_custom_workflows/errors/workflow_error.rb +++ b/lib/redmine_custom_workflows/errors/workflow_error.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # @@ -23,7 +24,7 @@ class WorkflowError < StandardError attr_accessor :error def initialize(message) - @error = message.dup + @error = message super message end end \ No newline at end of file diff --git a/lib/redmine_custom_workflows/hooks/hooks.rb b/lib/redmine_custom_workflows/hooks/hooks.rb index d3f7cba..8c4dd9b 100644 --- a/lib/redmine_custom_workflows/hooks/hooks.rb +++ b/lib/redmine_custom_workflows/hooks/hooks.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/lib/redmine_custom_workflows/patches/attachment_patch.rb b/lib/redmine_custom_workflows/patches/attachment_patch.rb index e73fbd1..a899e88 100644 --- a/lib/redmine_custom_workflows/patches/attachment_patch.rb +++ b/lib/redmine_custom_workflows/patches/attachment_patch.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/lib/redmine_custom_workflows/patches/group_patch.rb b/lib/redmine_custom_workflows/patches/group_patch.rb index de7d18c..879adfa 100644 --- a/lib/redmine_custom_workflows/patches/group_patch.rb +++ b/lib/redmine_custom_workflows/patches/group_patch.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/lib/redmine_custom_workflows/patches/issue_patch.rb b/lib/redmine_custom_workflows/patches/issue_patch.rb index 1ad2a6b..4ddf416 100644 --- a/lib/redmine_custom_workflows/patches/issue_patch.rb +++ b/lib/redmine_custom_workflows/patches/issue_patch.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/lib/redmine_custom_workflows/patches/mailer_patch.rb b/lib/redmine_custom_workflows/patches/mailer_patch.rb index 10c9d92..62e93d2 100644 --- a/lib/redmine_custom_workflows/patches/mailer_patch.rb +++ b/lib/redmine_custom_workflows/patches/mailer_patch.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/lib/redmine_custom_workflows/patches/project_patch.rb b/lib/redmine_custom_workflows/patches/project_patch.rb index 93206ba..fccdd19 100644 --- a/lib/redmine_custom_workflows/patches/project_patch.rb +++ b/lib/redmine_custom_workflows/patches/project_patch.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/lib/redmine_custom_workflows/patches/projects_helper_patch.rb b/lib/redmine_custom_workflows/patches/projects_helper_patch.rb index ac353a8..d274508 100644 --- a/lib/redmine_custom_workflows/patches/projects_helper_patch.rb +++ b/lib/redmine_custom_workflows/patches/projects_helper_patch.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/lib/redmine_custom_workflows/patches/time_entry_patch.rb b/lib/redmine_custom_workflows/patches/time_entry_patch.rb index 563a1ae..295ed95 100644 --- a/lib/redmine_custom_workflows/patches/time_entry_patch.rb +++ b/lib/redmine_custom_workflows/patches/time_entry_patch.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/lib/redmine_custom_workflows/patches/user_patch.rb b/lib/redmine_custom_workflows/patches/user_patch.rb index 31934ae..c08901d 100644 --- a/lib/redmine_custom_workflows/patches/user_patch.rb +++ b/lib/redmine_custom_workflows/patches/user_patch.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/lib/redmine_custom_workflows/patches/version_patch.rb b/lib/redmine_custom_workflows/patches/version_patch.rb index 9c9e0ed..a196afe 100644 --- a/lib/redmine_custom_workflows/patches/version_patch.rb +++ b/lib/redmine_custom_workflows/patches/version_patch.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/lib/redmine_custom_workflows/patches/wiki_content_patch.rb b/lib/redmine_custom_workflows/patches/wiki_content_patch.rb index 3b7bfc0..ffc1539 100644 --- a/lib/redmine_custom_workflows/patches/wiki_content_patch.rb +++ b/lib/redmine_custom_workflows/patches/wiki_content_patch.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/lib/redmine_custom_workflows/patches/wiki_page_patch.rb b/lib/redmine_custom_workflows/patches/wiki_page_patch.rb index 228bc6b..3acbc3e 100644 --- a/lib/redmine_custom_workflows/patches/wiki_page_patch.rb +++ b/lib/redmine_custom_workflows/patches/wiki_page_patch.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/lib/redmine_custom_workflows/test/test_case.rb b/lib/redmine_custom_workflows/test/test_case.rb index 8407c3c..60c926d 100644 --- a/lib/redmine_custom_workflows/test/test_case.rb +++ b/lib/redmine_custom_workflows/test/test_case.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/lib/redmine_custom_workflows/test/unit_test.rb b/lib/redmine_custom_workflows/test/unit_test.rb index 0db152d..feddf31 100644 --- a/lib/redmine_custom_workflows/test/unit_test.rb +++ b/lib/redmine_custom_workflows/test/unit_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/test/ci/redmine_install.sh b/test/ci/redmine_install.sh index d9d353f..0ffa5d5 100644 --- a/test/ci/redmine_install.sh +++ b/test/ci/redmine_install.sh @@ -21,7 +21,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. export REDMINE_GIT_REPO=git://github.com/redmine/redmine.git -export REDMINE_GIT_TAG=4.0-stable +export REDMINE_GIT_TAG=4.1-stable clone() { diff --git a/test/fixtures/custom_workflows.yml b/test/fixtures/custom_workflows.yml index 9e878c1..776155a 100644 --- a/test/fixtures/custom_workflows.yml +++ b/test/fixtures/custom_workflows.yml @@ -4,7 +4,7 @@ custom_workflows_001: before_save: "Rails.logger.info '>>> before save'" after_save: "Rails.logger.info '>>> after save'" name: 'Issue CW test' - description: NULL + description: 'Testing workflow' position: 1 is_for_all: 0 author: 'karel.picman@kontron.com' diff --git a/test/functional/custom_workflows_controller_test.rb b/test/functional/custom_workflows_controller_test.rb index 13e858d..74f8c75 100644 --- a/test/functional/custom_workflows_controller_test.rb +++ b/test/functional/custom_workflows_controller_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/test/test_helper.rb b/test/test_helper.rb index 867893b..c26fb3f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/test/unit/custom_workflow_mailer_test.rb b/test/unit/custom_workflow_mailer_test.rb index 6c42c13..fbc5cb4 100644 --- a/test/unit/custom_workflow_mailer_test.rb +++ b/test/unit/custom_workflow_mailer_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/test/unit/custom_workflow_test.rb b/test/unit/custom_workflow_test.rb index 551b488..f970118 100644 --- a/test/unit/custom_workflow_test.rb +++ b/test/unit/custom_workflow_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows # diff --git a/test/unit_test.rb b/test/unit_test.rb index 8c9eaf6..ce23f22 100644 --- a/test/unit_test.rb +++ b/test/unit_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true # # Redmine plugin for Custom Workflows #