Skip to content

Commit

Permalink
working on redmine 6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandermeindl committed Nov 10, 2024
1 parent 9c97e7f commit c58d271
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 103 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ jobs:

strategy:
matrix:
ruby: ['3.1', '3.2']
redmine: ['5.0-stable', '5.1-stable', 'master']
ruby: ['3.1', '3.2', '3.3']
redmine: ['6.0-stable', 'master']
db: ['postgres', 'mysql']
exclude:
- ruby: '3.2'
redmine: 5.0-stable
fail-fast: false

services:
Expand Down
3 changes: 1 addition & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require:

AllCops:
TargetRubyVersion: 3.1
TargetRailsVersion: 6.1
TargetRailsVersion: 7.2
NewCops: enable
ActiveSupportExtensionsEnabled: true

Expand Down Expand Up @@ -50,7 +50,6 @@ Metrics/PerceivedComplexity:
Style/ExpandPathArguments:
Enabled: true
Exclude:
- additional_tags.gemspec
- test/**/*

Rails/ApplicationJob:
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

# Specify your gem's dependencies in additional_tags.gemspec
gemspec
gem 'acts-as-taggable-on'
gem 'redmine_plugin_kit'

# if you want to use it for linters, do:
# - create .enable_test file in additionals directory
Expand Down
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,6 @@ git clone -b stable https://www.github.com/alphanodes/additionals.git plugins/ad
git clone -b stable https://www.github.com/alphanodes/additional_tags.git plugins/additional_tags
```

It is also possible to use stable version as a gem package as an alternative. If you want it, add this to your $REDMINE_ROOT/Gemfile.local:

```ruby
gem 'additional_tags'
```

At the moment, additionals should be installed before using gem method. In later versions
addtionals plugins is usable as gem, too.

If you want to use the latest development version, use

```shell
Expand Down
13 changes: 0 additions & 13 deletions Rakefile

This file was deleted.

27 changes: 0 additions & 27 deletions additional_tags.gemspec

This file was deleted.

2 changes: 1 addition & 1 deletion app/jobs/additional_tags_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class AdditionalTagsJob < AdditionalsJob
class AdditionalTagsJob < ApplicationJob
queue_as :additional_tags
end
2 changes: 1 addition & 1 deletion app/models/migrate_tag.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class MigrateTag < AdditionalsApplicationRecord
class MigrateTag < ApplicationRecord
self.table_name = 'tags'
has_many :migrate_taggings, dependent: :destroy, foreign_key: :tag_id, inverse_of: :migrate_tag
end
2 changes: 1 addition & 1 deletion app/models/migrate_tagging.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class MigrateTagging < AdditionalsApplicationRecord
class MigrateTagging < ApplicationRecord
self.table_name = 'taggings'
belongs_to :migrate_tag, foreign_key: :tag_id, inverse_of: :migrate_taggings
belongs_to :taggable, polymorphic: true
Expand Down
8 changes: 2 additions & 6 deletions init.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
# frozen_string_literal: true

require 'additional_tags/plugin_version'

loader = RedminePluginKit::Loader.new plugin_id: 'additional_tags'

Redmine::Plugin.register :additional_tags do
name 'Additional Tags'
author 'AlphaNodes GmbH'
description 'Redmine tagging support'
version AdditionalTags::PluginVersion::VERSION
version AdditionalTags::VERSION
url 'https://github.com/alphanodes/additional_tags/'
author_url 'https://alphanodes.com/'
directory File.dirname(__FILE__)

requires_redmine version_or_higher: '5.0'
requires_redmine version_or_higher: '5.1' # redmine 6.0 is required, but version is not set in redmine source yet

settings default: loader.default_settings,
partial: 'additional_tags/settings/settings'
Expand Down
46 changes: 17 additions & 29 deletions lib/additional_tags.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# frozen_string_literal: true

require 'redmine_plugin_kit'
require 'acts-as-taggable-on'

module AdditionalTags
VERSION = '4.0.0-main'

TAG_TABLE_NAME = 'additional_tags'
TAGGING_TABLE_NAME = 'additional_taggings'

Expand All @@ -22,7 +23,21 @@ def use_colors?
private

def setup
raise 'Please install additionals plugin (https://github.com/alphanodes/additionals)' unless Redmine::Plugin.installed? 'additionals'
begin
Redmine::Plugin.find 'additionals'
rescue Redmine::PluginNotFound
# rubocop: disable Style/RaiseArgs
raise Redmine::PluginRequirementError.new "#{plugin_id} plugin requires the additionals plugin. " \
'Please install additionals plugin (https://github.com/alphanodes/additionals)'
# rubocop: enable Style/RaiseArgs
end

ActsAsTaggableOn.tags_table = TAG_TABLE_NAME
ActsAsTaggableOn.taggings_table = TAGGING_TABLE_NAME
# NOTE: remove_unused_tags cannot be used, because tag is deleted before assign for tagging
# @see https://github.com/mbleigh/acts-as-taggable-on/issues/946
# NOTE2: merging tags is not compatible, too.
ActsAsTaggableOn.remove_unused_tags = false

loader.incompatible? %w[redmine_tags
redmine_tagging
Expand Down Expand Up @@ -65,31 +80,4 @@ def setup
loader.load_view_hooks!
end
end

# Run the classic redmine plugin initializer after rails boot
class Plugin < ::Rails::Engine
require 'additional_tags/tags'

ActsAsTaggableOn.tags_table = TAG_TABLE_NAME
ActsAsTaggableOn.taggings_table = TAGGING_TABLE_NAME
# NOTE: remove_unused_tags cannot be used, because tag is deleted before assign for tagging
# @see https://github.com/mbleigh/acts-as-taggable-on/issues/946
# NOTE2: merging tags is not compatible, too.
ActsAsTaggableOn.remove_unused_tags = false

config.after_initialize do
# engine_name could be used (additional_tags_plugin), but can
# create some side effects
plugin_id = 'additional_tags'

# if plugin is already in plugins directory, use this and leave here
next if Redmine::Plugin.installed? plugin_id

# gem is used as redmine plugin
require File.expand_path '../init', __dir__
AdditionalTags.setup!
Additionals::Gemify.install_assets plugin_id
Additionals::Gemify.create_plugin_hint plugin_id
end
end
end
7 changes: 0 additions & 7 deletions lib/additional_tags/plugin_version.rb

This file was deleted.

0 comments on commit c58d271

Please sign in to comment.