diff --git a/.github/workflows/4_2_9.yml b/.github/workflows/4_2_11.yml similarity index 98% rename from .github/workflows/4_2_9.yml rename to .github/workflows/4_2_11.yml index f6675a6..749b0de 100644 --- a/.github/workflows/4_2_9.yml +++ b/.github/workflows/4_2_11.yml @@ -1,8 +1,8 @@ -name: Tests 4.2.9 +name: Tests 4.2.11 env: PLUGIN_NAME: redmine_base_deface - REDMINE_VERSION: 4.2.9 + REDMINE_VERSION: 4.2.11 RAILS_ENV: test on: diff --git a/.github/workflows/5_0_4.yml b/.github/workflows/5_0_6.yml similarity index 98% rename from .github/workflows/5_0_4.yml rename to .github/workflows/5_0_6.yml index 652d338..8ea8ab5 100644 --- a/.github/workflows/5_0_4.yml +++ b/.github/workflows/5_0_6.yml @@ -1,8 +1,8 @@ -name: Tests 5.0.4 +name: Tests 5.0.6 env: PLUGIN_NAME: redmine_base_deface - REDMINE_VERSION: 5.0.4 + REDMINE_VERSION: 5.0.6 RAILS_ENV: test on: @@ -16,7 +16,7 @@ jobs: strategy: matrix: - ruby: ['2.7'] + ruby: ['3.1'] db: ['postgres'] fail-fast: false diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..c7da51e --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.history +.byebug_history +tmp +.ruby-lsp diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..5cef9ff --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,46 @@ +AllCops: + NewCops: enable + DisplayCopNames: true + DisplayStyleGuide: true + TargetRubyVersion: 3.1 + + Exclude: + - '**/vendor/**/*' + - '**/tmp/**/*' + - '**/bin/**/*' + - '**/extra/**/*' + - '**/lib/generators/**/templates/*' + - '**/lib/tasks/**/*' + - '**/files/**/*' + - '**/test/**/*' + - '**/db/migrate/*' + - 'db/schema.rb' + - '**/*_patch.rb' + +require: + - rubocop-performance + - rubocop-rails + - rubocop-minitest + - rubocop-rake + +Style/FrozenStringLiteralComment: + Enabled: true + EnforcedStyle: always + Exclude: + - 'db/**/*.rb' + - 'Gemfile' + - 'Rakefile' + +Metrics/AbcSize: + Exclude: + - 'test/**/*' + +Metrics/MethodLength: + Exclude: + - 'test/**/*' + +Layout/LineLength: + Max: 120 + +Style/Documentation: + Enabled: false diff --git a/Gemfile b/Gemfile new file mode 100755 index 0000000..ea137bc --- /dev/null +++ b/Gemfile @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +source 'https://rubygems.org' + +# Supports Rails 6 +gem 'deface', '1.8.2' + +# Supports Rails 5.2 +# gem 'deface', '1.6.2' diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/PluginGemfile b/PluginGemfile deleted file mode 100644 index 4fba61c..0000000 --- a/PluginGemfile +++ /dev/null @@ -1,3 +0,0 @@ -# Later version of the Deface gem may not be fully compatible with Rails 5.2 & Redmine 4.2 -# bug described here: https://www.redmine.org/issues/35430 -gem 'deface', '1.6.2' diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 4d61b65..3d6a2fd --- a/README.md +++ b/README.md @@ -24,12 +24,12 @@ Test status |Plugin branch| Redmine Version | Test Status | |-------------|-----------------|-------------------| -|master | 5.0.4 | [![5.0.4][1]][5] | -|master | 4.2.9 | [![4.2.9][2]][5] | +|master | 5.0.6 | [![5.0.6][1]][5] | +|master | 4.2.11 | [![4.2.11][2]][5] | |master | master | [![master][4]][5] | -[1]: https://github.com/jbbarth/redmine_base_deface/actions/workflows/5_0_4.yml/badge.svg -[2]: https://github.com/jbbarth/redmine_base_deface/actions/workflows/4_2_9.yml/badge.svg +[1]: https://github.com/jbbarth/redmine_base_deface/actions/workflows/5_0_6.yml/badge.svg +[2]: https://github.com/jbbarth/redmine_base_deface/actions/workflows/4_2_11.yml/badge.svg [4]: https://github.com/jbbarth/redmine_base_deface/actions/workflows/master.yml/badge.svg [5]: https://github.com/jbbarth/redmine_base_deface/actions diff --git a/app/overrides/README.txt b/app/overrides/README.txt old mode 100644 new mode 100755 diff --git a/init.rb b/init.rb old mode 100644 new mode 100755 index 4c861a9..b4e57aa --- a/init.rb +++ b/init.rb @@ -1,12 +1,14 @@ +# frozen_string_literal: true + Redmine::Plugin.register :redmine_base_deface do name 'Redmine Base Deface plugin' author 'Jean-Baptiste BARTH' description 'This is a plugin for Redmine' - version '1.6.2' + version '1.8.2-xmr' url 'https://github.com/jbbarth/redmine_base_deface' author_url 'jeanbaptiste.barth@gmail.com' - #doesn't work since redmine evaluates dependencies as it loads, and loads in lexical order - #TODO: see if it works in Redmine 2.6.x or 3.x when they're released + # doesn't work since redmine evaluates dependencies as it loads, and loads in lexical order + # TODO: see if it works in Redmine 2.6.x or 3.x when they're released # requires_redmine_plugin :redmine_base_rspec, :version_or_higher => '0.0.3' if Rails.env.test? end @@ -15,21 +17,24 @@ # - deface doesn't support direct loading anymore ; it unloads everything at boot so that reload in dev works # - hack consists in adding "app/overrides" path of all plugins in Redmine's main #paths if Rails.version > '6.0' - Dir.glob("#{Rails.root}/plugins/*/app/overrides/**/*.rb").each do |path| - Rails.autoloaders.main.ignore(path) - load File.expand_path(path, __FILE__) + # Do not require overrides when deface has precompiled views + unless Rails.application.try(:config).try(:deface).try(:enabled) == false + Dir.glob(Rails.root.join('plugins/*/app/overrides/**/*.rb').to_s).each do |path| + Rails.autoloaders.main.ignore(path) + load File.expand_path(path, __FILE__) + end end Rails.application.config.after_initialize do - require_relative "lib/applicator_patch" + require_relative 'lib/applicator_patch' end else - Rails.application.paths["app/overrides"] ||= [] - Dir.glob("#{Rails.root}/plugins/*/app/overrides").each do |dir| - Rails.application.paths["app/overrides"] << dir unless Rails.application.paths["app/overrides"].include?(dir) + Rails.application.paths['app/overrides'] ||= [] + Dir.glob(Rails.root.join('plugins/*/app/overrides').to_s).each do |dir| + Rails.application.paths['app/overrides'] << dir unless Rails.application.paths['app/overrides'].include?(dir) end ActiveSupport::Reloader.to_prepare do - require_dependency "applicator_patch" + require_dependency 'applicator_patch' end end diff --git a/spec/models/applicator_patch_spec.rb b/spec/models/applicator_patch_spec.rb index 71d79f7..c1fac39 100644 --- a/spec/models/applicator_patch_spec.rb +++ b/spec/models/applicator_patch_spec.rb @@ -14,18 +14,19 @@ def self.all module Deface describe Applicator do - # include_context "mock Rails.application" before { Dummy.all.clear } - describe "source containing a javascript tag" do - before { Deface::Override.new(:virtual_path => "posts/index", - :name => "Posts#index", - :remove => "p") } + describe 'source containing a javascript tag' do + before do + Deface::Override.new(virtual_path: 'posts/index', + name: 'Posts#index', + remove: 'p') + end let(:source) { "<%= javascript_tag do %>if (y > 0) {y = 0;}<% end %>" } - it "should return unmodified source" do - expect(Dummy.apply(source, { :virtual_path => "posts/index" })).to eq("<%= javascript_tag do %>if (y > 0) {y = 0;}<% end %>") + it 'should return unmodified source' do + expect(Dummy.apply(source, { virtual_path: 'posts/index' })).to eq("<%= javascript_tag do %>if (y > 0) {y = 0;}<% end %>") end end end diff --git a/spec/models/deface_paths_spec.rb b/spec/models/deface_paths_spec.rb old mode 100644 new mode 100755 index 78c5c4e..0b9fbdd --- a/spec/models/deface_paths_spec.rb +++ b/spec/models/deface_paths_spec.rb @@ -1,12 +1,15 @@ -require "spec_helper" +# frozen_string_literal: true -describe "DefacePaths" do +require 'spec_helper' + +describe 'DefacePaths' do if Rails.version < '6.0' - it "overrides app paths" do - overrides_paths = Rails.application.paths["app/overrides"] - this_plugin_paths = Rails.root.join("plugins/redmine_base_deface/app/overrides") + it 'overrides app paths' do + overrides_paths = Rails.application.paths['app/overrides'] + this_plugin_paths = Rails.root.join('plugins/redmine_base_deface/app/overrides') expect(overrides_paths).to include(this_plugin_paths.to_s), - "The init.rb of this very plugin should add every plugins' app/overrides to rails paths for app/overrides" + "The init.rb of this very plugin should add every plugins' app/overrides \ + to rails paths for app/overrides" end end end