Skip to content

Commit

Permalink
Merge pull request #138 from southbridgeio/redmine_5.1_compatibility
Browse files Browse the repository at this point in the history
add compatibility with Redmine 5.1
  • Loading branch information
nevrfl authored Oct 9, 2024
2 parents c08d5c0 + 7b930c9 commit a0c8065
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: ruby
rvm:
- 2.4.9
- 2.6.5
- 2.7.2

#branches:
# only:
Expand All @@ -14,6 +15,7 @@ addons:
env:
- REDMINE_VER=3.4-stable
- REDMINE_VER=4.1-stable
- REDMINE_VER=5.1-stable

install: "echo skip bundle install"

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.6.1

* Change foreign key to issue
* Add compatibility with Redmine 5.1

# 1.6.0

* Send live notifications for closed issues
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/settings_templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def edit
def update
@settings_template = SettingsTemplate.find(params[:id])
@settings_template.intouch_settings = params[:intouch_settings].to_unsafe_h
if @settings_template.update_attributes(settings_template_params)
if @settings_template.update_attribute(:name, settings_template_params[:name])
flash[:notice] = l(:notice_successful_update)
redirect_to controller: 'settings_templates', action: 'edit', id: @settings_template
else
Expand Down
15 changes: 10 additions & 5 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@

FileUtils.mkdir_p(Rails.root.join('log/intouch')) unless Dir.exist?(Rails.root.join('log/intouch'))

require 'intouch'
require './plugins/redmine_intouch/lib/intouch'
require 'telegram/bot'

# Rails 5.1/Rails 4
reloader = defined?(ActiveSupport::Reloader) ? ActiveSupport::Reloader : ActionDispatch::Reloader
reloader.to_prepare do
register_after_redmine_initialize_proc =
if Redmine::VERSION::MAJOR >= 5
Rails.application.config.public_method(:after_initialize)
else
reloader = defined?(ActiveSupport::Reloader) ? ActiveSupport::Reloader : ActionDispatch::Reloader
reloader.public_method(:to_prepare)
end
register_after_redmine_initialize_proc.call do
paths = '/lib/intouch/{patches/*_patch,hooks/*_hook}.rb'
Dir.glob(File.dirname(__FILE__) + paths).each do |file|
require_dependency file
end

require_dependency 'redmine_bots'
require_dependency './plugins/redmine_bots/lib/redmine_bots'
end

paths = Dir.glob("#{Rails.application.config.root}/plugins/redmine_intouch/{lib,app/workers,app/models,app/controllers}")
Expand Down
2 changes: 1 addition & 1 deletion lib/intouch/patches/project_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def self.included(base) # :nodoc:

def assigner_ids
Group.where(id: active_assigner_groups).try(:map, &:user_ids).try(:flatten).try(:uniq) |
users_by_role.select { |role, users| role.id.to_s.in?(active_assigner_roles) }.map(&:last).flatten.uniq.map(&:id)
principals_by_role.select { |role, users| role.id.to_s.in?(active_assigner_roles) }.map(&:last).flatten.uniq.map(&:id)
end

def active_assigner_groups
Expand Down

0 comments on commit a0c8065

Please sign in to comment.