alias_method_chain is deprecated

This commit is contained in:
Karel Picman 2017-12-19 14:52:53 +01:00
parent e8c3e1a9cf
commit 53112b2917
2 changed files with 11 additions and 18 deletions

View File

@ -15,13 +15,12 @@ end
require 'redmine_custom_workflows/hooks'
require File.dirname(__FILE__) + '/lib/redmine_custom_workflows/projects_helper_patch'
Rails.application.config.to_prepare do
unless Project.include?(RedmineCustomWorkflows::ProjectPatch)
Project.send(:include, RedmineCustomWorkflows::ProjectPatch)
end
unless ProjectsHelper.include?(RedmineCustomWorkflows::ProjectsHelperPatch)
ProjectsHelper.send(:include, RedmineCustomWorkflows::ProjectsHelperPatch)
end
unless Attachment.include?(RedmineCustomWorkflows::AttachmentPatch)
Attachment.send(:include, RedmineCustomWorkflows::AttachmentPatch)
end

View File

@ -1,20 +1,14 @@
module RedmineCustomWorkflows
module ProjectsHelperPatch
def self.included(base)
base.send(:include, InstanceMethods)
base.class_eval do
alias_method_chain :project_settings_tabs, :custom_workflows
end
def project_settings_tabs
tabs = super
tabs << {:name => 'custom_workflows', :action => :manage_project_workflow, :partial => 'projects/settings/custom_workflow',
:label => :label_custom_workflow_plural} if User.current.allowed_to?(:manage_project_workflow, @project)
tabs
end
module InstanceMethods
def project_settings_tabs_with_custom_workflows
tabs = project_settings_tabs_without_custom_workflows
tabs << {:name => 'custom_workflows', :action => :manage_project_workflow, :partial => 'projects/settings/custom_workflow',
:label => :label_custom_workflow_plural} if User.current.allowed_to?(:manage_project_workflow, @project)
tabs
end
end
end
end
ProjectsHelper.send(:prepend, RedmineCustomWorkflows::ProjectsHelperPatch)