From b68d2d9f6fb91466d15cfc6d4961aa973a13bd27 Mon Sep 17 00:00:00 2001 From: Alexander Meindl Date: Sun, 22 Dec 2019 09:05:18 +0100 Subject: [PATCH] Working on Redmine 4.1 support; drop Redmine 3.x support --- .rubocop.yml | 20 ++++++++++------ .travis.yml | 26 +++++---------------- CHANGELOG.md | 7 ++++++ Gemfile | 2 -- README.md | 2 +- db/migrate/001_create_messenger_settings.rb | 2 +- db/migrate/002_add_default_mentions.rb | 2 +- db/migrate/003_add_private_settings.rb | 2 +- init.rb | 4 ++-- lib/redmine_messenger.rb | 23 +++++++----------- test/unit/i18n_test.rb | 6 +---- 11 files changed, 42 insertions(+), 54 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index f6bb2ef..8bdfaf5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,6 @@ require: - rubocop-performance + - rubocop-rails Rails: Enabled: true @@ -15,32 +16,37 @@ Metrics/BlockLength: Max: 60 Metrics/ClassLength: - Max: 500 + Enabled: false Metrics/CyclomaticComplexity: Max: 20 -Metrics/LineLength: +Layout/LineLength: Max: 140 Metrics/MethodLength: Max: 60 Metrics/ModuleLength: - Max: 500 + Enabled: false Metrics/PerceivedComplexity: Max: 25 -Rails/SkipsModelValidations: +Rails/ApplicationJob: + Enabled: false + +Rails/ApplicationRecord: Enabled: false Rails/CreateTableWithTimestamps: Enabled: false -# we drop this, if we drop Rails 4.2 support -Rails/ApplicationRecord: - Enabled: false +Rails/HelperInstanceVariable: + Enabled: false + +Rails/SkipsModelValidations: + Enabled: false Performance/ChainArrayAllocation: Enabled: true diff --git a/.travis.yml b/.travis.yml index 4d2a924..89e34b9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,9 @@ language: ruby dist: xenial rvm: - - 2.6.3 - - 2.5.5 - - 2.4.6 + - 2.6.5 + - 2.5.7 + - 2.4.9 services: - mysql @@ -12,23 +12,12 @@ services: env: - REDMINE_VER=4.0-stable DB=postgresql - - REDMINE_VER=3.4-stable DB=postgresql + - REDMINE_VER=master DB=postgresql - REDMINE_VER=4.0-stable DB=mysql - - REDMINE_VER=3.4-stable DB=mysql + - REDMINE_VER=master DB=mysql sudo: true -matrix: - exclude: - - rvm: 2.6.3 - env: REDMINE_VER=3.4-stable DB=mysql - - rvm: 2.6.3 - env: REDMINE_VER=3.4-stable DB=postgresql - - rvm: 2.5.5 - env: REDMINE_VER=3.4-stable DB=mysql - - rvm: 2.5.5 - env: REDMINE_VER=3.4-stable DB=postgresql - notifications: webhooks: urls: @@ -54,7 +43,4 @@ before_script: script: - export SKIP_COVERAGE=1 - - if [[ "$REDMINE_VER" == "master" ]]; then bundle exec rake redmine:plugins:test:units NAME=$PLUGIN_NAME; fi - - if [[ "$REDMINE_VER" == "master" ]]; then bundle exec rake redmine:plugins:test:functionals NAME=$PLUGIN_NAME; fi - - if [[ "$REDMINE_VER" == "master" ]]; then bundle exec rake redmine:plugins:test:integration NAME=$PLUGIN_NAME; fi - - if [[ "$REDMINE_VER" != "master" ]]; then bundle exec rake redmine:plugins:test NAME=$PLUGIN_NAME RUBYOPT="-W0"; fi + - bundle exec rake redmine:plugins:test NAME=$PLUGIN_NAME RUBYOPT="-W0" diff --git a/CHANGELOG.md b/CHANGELOG.md index e8e2408..8651367 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ Changelog ========= +1.0.6 +----- + +- Redmine 4 is required +- Redmine 4.1 support + + 1.0.5 ----- diff --git a/Gemfile b/Gemfile index cd397d6..474e102 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,4 @@ gem 'validate_url' group :development, :test do gem 'brakeman', require: false - gem 'rubocop', require: false - gem 'rubocop-performance', require: false end diff --git a/README.md b/README.md index bf9d036..f54f17b 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Go to Rocket.Chat documentation [Incoming WebHook Scripting](https://rocket.chat Requirements ------------ -* Redmine version >= 3.0.0 +* Redmine version >= 4.0.0 * Ruby version >= 2.4.0 diff --git a/db/migrate/001_create_messenger_settings.rb b/db/migrate/001_create_messenger_settings.rb index 0fe489a..392db49 100644 --- a/db/migrate/001_create_messenger_settings.rb +++ b/db/migrate/001_create_messenger_settings.rb @@ -1,4 +1,4 @@ -class CreateMessengerSettings < Rails.version < '5.2' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2] +class CreateMessengerSettings < ActiveRecord::Migration[4.2] def change create_table :messenger_settings do |t| t.references :project, null: false, index: true diff --git a/db/migrate/002_add_default_mentions.rb b/db/migrate/002_add_default_mentions.rb index 1412e78..3f5221f 100644 --- a/db/migrate/002_add_default_mentions.rb +++ b/db/migrate/002_add_default_mentions.rb @@ -1,4 +1,4 @@ -class AddDefaultMentions < Rails.version < '5.2' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2] +class AddDefaultMentions < ActiveRecord::Migration[4.2] def change add_column :messenger_settings, :default_mentions, :string end diff --git a/db/migrate/003_add_private_settings.rb b/db/migrate/003_add_private_settings.rb index bd89d42..f9194c3 100644 --- a/db/migrate/003_add_private_settings.rb +++ b/db/migrate/003_add_private_settings.rb @@ -1,4 +1,4 @@ -class AddPrivateSettings < Rails.version < '5.2' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2] +class AddPrivateSettings < ActiveRecord::Migration[4.2] def change add_column :messenger_settings, :post_private_contacts, :integer, default: 0, null: false add_column :messenger_settings, :post_private_db, :integer, default: 0, null: false diff --git a/init.rb b/init.rb index 71d20e2..29e0ea9 100644 --- a/init.rb +++ b/init.rb @@ -8,9 +8,9 @@ Redmine::Plugin.register :redmine_messenger do url 'https://github.com/alphanodes/redmine_messenger' author_url 'https://alphanodes.com/' description 'Messenger integration for Slack, Discord, Rocketchat and Mattermost support' - version '1.0.5' + version '1.0.6' - requires_redmine version_or_higher: '3.0.0' + requires_redmine version_or_higher: '4.0.0' permission :manage_messenger, projects: :settings, messenger_settings: :update diff --git a/lib/redmine_messenger.rb b/lib/redmine_messenger.rb index 2476a13..8de5dc5 100644 --- a/lib/redmine_messenger.rb +++ b/lib/redmine_messenger.rb @@ -7,15 +7,15 @@ module RedmineMessenger class << self def setup # Patches - Issue.send(:include, RedmineMessenger::Patches::IssuePatch) - WikiPage.send(:include, RedmineMessenger::Patches::WikiPagePatch) + Issue.include RedmineMessenger::Patches::IssuePatch + WikiPage.include RedmineMessenger::Patches::WikiPagePatch ProjectsController.send :helper, MessengerProjectsHelper - Contact.send(:include, RedmineMessenger::Patches::ContactPatch) if RedmineMessenger::REDMINE_CONTACTS_SUPPORT - DbEntry.send(:include, RedmineMessenger::Patches::DbEntryPatch) if RedmineMessenger::REDMINE_DB_SUPPORT - Password.send(:include, RedmineMessenger::Patches::PasswordPatch) if Redmine::Plugin.installed?('redmine_passwords') + Contact.include(RedmineMessenger::Patches::ContactPatch) if RedmineMessenger::REDMINE_CONTACTS_SUPPORT + DbEntry.include(RedmineMessenger::Patches::DbEntryPatch) if RedmineMessenger::REDMINE_DB_SUPPORT + Password.include(RedmineMessenger::Patches::PasswordPatch) if Redmine::Plugin.installed?('redmine_passwords') # Global helpers - ActionView::Base.send :include, RedmineMessenger::Helpers + ActionView::Base.include RedmineMessenger::Helpers # Hooks require_dependency 'redmine_messenger/hooks' @@ -23,14 +23,9 @@ module RedmineMessenger def settings if Setting[:plugin_redmine_messenger].class == Hash - if Rails.version >= '5.2' - # convert Rails 4 data - new_settings = ActiveSupport::HashWithIndifferentAccess.new(Setting[:plugin_redmine_messenger]) - Setting.plugin_redmine_messenger = new_settings - new_settings - else - ActionController::Parameters.new(Setting[:plugin_redmine_messenger]) - end + new_settings = ActiveSupport::HashWithIndifferentAccess.new(Setting[:plugin_redmine_messenger]) + Setting.plugin_redmine_messenger = new_settings + new_settings else # Rails 5 uses ActiveSupport::HashWithIndifferentAccess Setting[:plugin_redmine_messenger] diff --git a/test/unit/i18n_test.rb b/test/unit/i18n_test.rb index cccaa19..8e2dbda 100644 --- a/test/unit/i18n_test.rb +++ b/test/unit/i18n_test.rb @@ -17,11 +17,7 @@ class I18nTest < ActiveSupport::TestCase end def test_locales_validness - lang_files_count = Dir[Rails.root.join('plugins', - 'redmine_messenger', - 'config', - 'locales', - '*.yml')].size + lang_files_count = Dir[Rails.root.join('plugins/redmine_messenger/config/locales/*.yml')].size assert_equal lang_files_count, 4 valid_languages.each do |lang| assert set_language_if_valid(lang)