diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b40438e..23f85fa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,36 +17,32 @@ on: jobs: test: name: redmine:${{ matrix.redmine_version }} ruby:${{ matrix.ruby_version }} db:${{ matrix.db }} - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 strategy: fail-fast: false matrix: - redmine_version: [4.2-stable, 5.0-stable, 5.1-stable, master] - ruby_version: ['2.7', '3.0', '3.1', '3.2'] + redmine_version: [5.0-stable, 5.1-stable, 6.0-stable, master] + ruby_version: ['3.1', '3.2', '3.3'] db: ['mysql:5.7', 'postgres:10', 'sqlite3'] # System test takes 2~3 times longer, so limit to specific matrix combinations # See: https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#expanding-or-adding-matrix-configurations include: - system_test: true - redmine_version: 5.1-stable - ruby_version: '3.2' + redmine_version: 6.0-stable + ruby_version: '3.3' db: 'mysql:5.7' exclude: - - redmine_version: 4.2-stable - ruby_version: '3.0' - - redmine_version: 4.2-stable - ruby_version: '3.1' - - redmine_version: 4.2-stable - ruby_version: '3.2' - redmine_version: 5.0-stable ruby_version: '3.2' - - redmine_version: master - ruby_version: '2.7' + - redmine_version: 5.0-stable + ruby_version: '3.3' + - redmine_version: 5.1-stable + ruby_version: '3.3' steps: - name: Setup Redmine - uses: hidakatsuya/action-setup-redmine@v1 + uses: hidakatsuya/action-setup-redmine@v2 with: repository: redmine/redmine version: ${{ matrix.redmine_version }} @@ -82,11 +78,11 @@ jobs: - name: Run plugin tests working-directory: redmine run: | - bundle exec rake redmine:plugins:test:units NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0" - bundle exec rake redmine:plugins:test:functionals NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0" - bundle exec rake redmine:plugins:test:integration NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0" + bundle exec rails test plugins/redmine_custom_fields_groups/test/unit + bundle exec rails test plugins/redmine_custom_fields_groups/test/functional + bundle exec rails test plugins/redmine_custom_fields_groups/test/integration if [ ${{ matrix.system_test }} = "true" ]; then - bundle exec rake redmine:plugins:test:system NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0" + bundle exec rails test plugins/redmine_custom_fields_groups/test/system fi # - name: Run core tests @@ -94,7 +90,7 @@ jobs: # RAILS_ENV: test # PARALLEL_WORKERS: 1 # working-directory: redmine - # run: bundle exec rake test + # run: bundle exec rails test # - name: Run core system tests # if: matrix.system_test == true @@ -102,7 +98,7 @@ jobs: # RAILS_ENV: test # GOOGLE_CHROME_OPTS_ARGS: "headless,disable-gpu,no-sandbox,disable-dev-shm-usage" # working-directory: redmine - # run: bundle exec rake test:system + # run: bundle exec rails test:system - name: Run uninstall test working-directory: redmine diff --git a/app/views/custom_fields_groups/index.html.erb b/app/views/custom_fields_groups/index.html.erb index 23ffa5d..28e4e6b 100644 --- a/app/views/custom_fields_groups/index.html.erb +++ b/app/views/custom_fields_groups/index.html.erb @@ -1,5 +1,7 @@
-<%= link_to l(:label_custom_fields_group_new), new_custom_fields_group_path, :class => 'icon icon-add' %> +<%= link_to (Redmine::VERSION.to_s >= '6.0.0') ? sprite_icon('add', l(:label_custom_fields_group_new)) : l(:label_custom_fields_group_new), + new_custom_fields_group_path, + :class => 'icon icon-add' %>
<%= title l :label_custom_fields_group_plural %> diff --git a/app/views/issues/_form_custom_fields.html.erb b/app/views/issues/_form_custom_fields.html.erb index 8b10191..9bd3bcb 100644 --- a/app/views/issues/_form_custom_fields.html.erb +++ b/app/views/issues/_form_custom_fields.html.erb @@ -35,10 +35,13 @@ <% end %> <% else %> <% fieldset_class = 'collapsible custom-fields-groups' + (all_collapsed ? ' collapsed' : '') %> - <% legend_class = 'icon icon-' + (all_collapsed ? 'collapsed' : ((Redmine::VERSION.to_s >= '5.0.0') ? 'expanded' : 'expended')) %> + <% legend_class = 'icon icon-' + (all_collapsed ? 'collapsed' : 'expanded') %> <% div_style = all_collapsed ? 'display: none' : '' %>
- <%= content_tag('legend', title, :onclick => "toggleFieldset(this);", :class => legend_class) %> + <%= content_tag('legend', + (Redmine::VERSION.to_s >= '6.0.0') ? sprite_icon(all_collapsed ? "angle-down" : "angle-right") + title : title, + :onclick => "toggleFieldset(this);", + :class => legend_class) %> <% if half_width_values.present? %>
diff --git a/assets/images/icons.svg b/assets/images/icons.svg new file mode 100644 index 0000000..330a00d --- /dev/null +++ b/assets/images/icons.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/assets/stylesheets/custom_fields_groups.css b/assets/stylesheets/custom_fields_groups.css index 839b1cf..fb10b25 100644 --- a/assets/stylesheets/custom_fields_groups.css +++ b/assets/stylesheets/custom_fields_groups.css @@ -1,4 +1,4 @@ -#admin-menu a.custom-fields-groups { background-image: url(../images/textfields_group.png);} +.icon-custom-fields-groups:not(:has(svg)) { background-image: url(../images/textfields_group.png); } h3.custom-fields-groups { background: #0001; diff --git a/config/icon_source.yml b/config/icon_source.yml new file mode 100644 index 0000000..95245be --- /dev/null +++ b/config/icon_source.yml @@ -0,0 +1,2 @@ +- name: custom-fields-groups + svg: list-check diff --git a/init.rb b/init.rb index f2236ea..c455939 100644 --- a/init.rb +++ b/init.rb @@ -7,9 +7,9 @@ author_url 'https://github.com/georepublic' url 'https://github.com/gtt-project/redmine_custom_fields_groups' description 'This is a plugin for grouping custom fields' - version '1.0.0' + version '2.0.0' - requires_redmine :version_or_higher => '4.1.0' + requires_redmine :version_or_higher => '5.0.0' settings partial: 'settings/redmine_custom_fields_groups', default: { @@ -22,23 +22,14 @@ { controller: 'custom_fields_groups', action: 'index' }, caption: :label_custom_fields_group_plural, after: :custom_fields, - html: { class: 'icon icon-custom-fields custom-fields-groups' } + html: { class: 'icon icon-custom-fields-groups' }, + icon: 'custom-fields-groups', plugin: :redmine_custom_fields_groups end -if Rails.version > '6.0' && Rails.autoloaders.zeitwerk_enabled? - Dir.glob("#{Rails.root}/plugins/redmine_custom_fields_groups/app/overrides/**/*.rb").each do |path| - Rails.autoloaders.main.ignore(path) - require path - end - Rails.application.config.after_initialize do - RedmineCustomFieldsGroups.setup - end -else - require 'redmine_custom_fields_groups' - Rails.application.paths["app/overrides"] ||= [] - Rails.application.paths["app/overrides"] << File.expand_path("../app/overrides", __FILE__) - - Rails.configuration.to_prepare do - RedmineCustomFieldsGroups.setup - end +Dir.glob("#{Rails.root}/plugins/redmine_custom_fields_groups/app/overrides/**/*.rb").each do |path| + Rails.autoloaders.main.ignore(path) + require path +end +Rails.application.config.after_initialize do + RedmineCustomFieldsGroups.setup end diff --git a/lib/redmine_custom_fields_groups/patches/issues_helper_patch.rb b/lib/redmine_custom_fields_groups/patches/issues_helper_patch.rb index 29bcd8f..fc1d211 100644 --- a/lib/redmine_custom_fields_groups/patches/issues_helper_patch.rb +++ b/lib/redmine_custom_fields_groups/patches/issues_helper_patch.rb @@ -45,8 +45,10 @@ def render_custom_fields_rows_by_groups(issue) s << render_full_width_custom_fields_rows_by_grouped_values(issue, values) else s << content_tag('fieldset', :class => 'collapsible custom-fields-groups') do - concat content_tag('legend', title, :onclick => 'toggleFieldset(this);', - :class => 'icon icon-' + ((Redmine::VERSION.to_s >= '5.0.0') ? 'expanded' : 'expended')) + concat content_tag('legend', + (Redmine::VERSION.to_s >= '6.0.0') ? sprite_icon('angle-down') + title : title, + :onclick => 'toggleFieldset(this);', + :class => 'icon icon-expanded') concat render_half_width_custom_fields_rows_by_grouped_values(issue, values) concat render_full_width_custom_fields_rows_by_grouped_values(issue, values) end diff --git a/test/functional/custom_fields_groups_controller_test.rb b/test/functional/custom_fields_groups_controller_test.rb index 7dea2ed..ef57e2b 100644 --- a/test/functional/custom_fields_groups_controller_test.rb +++ b/test/functional/custom_fields_groups_controller_test.rb @@ -7,6 +7,9 @@ class CustomFieldsGroupsControllerTest < ActionController::TestCase setup do User.current = nil @request.session[:user_id] = 1 # admin + if ActiveRecord::Base.connection_db_config.adapter == 'sqlite3' + load_plugin_fixtures(true) + end end teardown do diff --git a/test/integration/layout_test.rb b/test/integration/layout_test.rb index c3a8387..7511ce9 100644 --- a/test/integration/layout_test.rb +++ b/test/integration/layout_test.rb @@ -11,6 +11,9 @@ class LayoutTest < Redmine::IntegrationTest setup do User.current = nil @user = User.find_by_login('dlopper') + if ActiveRecord::Base.connection_db_config.adapter == 'sqlite3' + load_plugin_fixtures(true) + end end teardown do diff --git a/test/system/fieldset_test.rb b/test/system/fieldset_test.rb index d7b579b..4da6cab 100644 --- a/test/system/fieldset_test.rb +++ b/test/system/fieldset_test.rb @@ -8,6 +8,12 @@ class FieldsetTest < ApplicationSystemTestCase :watchers, :journals, :journal_details, :custom_fields, :custom_fields_groups, :custom_fields_group_fields + setup do + if ActiveRecord::Base.connection_db_config.adapter == 'sqlite3' + load_plugin_fixtures(true) + end + end + teardown do Setting.where(name: 'plugin_redmine_custom_fields_groups').destroy_all Setting.clear_cache diff --git a/test/test_helper.rb b/test/test_helper.rb index 99aca5d..c9d04f8 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,7 +1,14 @@ # Load the Redmine helper require_relative '../../../test/test_helper' -ActiveRecord::FixtureSet.create_fixtures( - File.dirname(__FILE__) + '/fixtures', - ['custom_fields_groups', 'custom_fields_group_fields'] -) +def load_plugin_fixtures(reset_cache = false) + if reset_cache + ActiveRecord::FixtureSet.reset_cache + end + ActiveRecord::FixtureSet.create_fixtures( + File.dirname(__FILE__) + '/fixtures', + ['custom_fields_groups', 'custom_fields_group_fields'] + ) +end + +load_plugin_fixtures diff --git a/test/unit/custom_fields_group_test.rb b/test/unit/custom_fields_group_test.rb index ea85586..61d2dd0 100644 --- a/test/unit/custom_fields_group_test.rb +++ b/test/unit/custom_fields_group_test.rb @@ -3,6 +3,12 @@ class CustomFieldsGroupTest < ActiveSupport::TestCase fixtures :custom_fields, :custom_fields_groups, :custom_fields_group_fields + setup do + if ActiveRecord::Base.connection_db_config.adapter == 'sqlite3' + load_plugin_fixtures(true) + end + end + test 'create' do issue_custom_field = IssueCustomField.new(:name => 'test', :field_format => 'text') issue_custom_field.save!