Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 16 additions & 20 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -82,27 +78,27 @@ 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
# env:
# 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
# env:
# 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
Expand Down
4 changes: 3 additions & 1 deletion app/views/custom_fields_groups/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<div class="contextual">
<%= 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' %>
</div>

<%= title l :label_custom_fields_group_plural %>
Expand Down
7 changes: 5 additions & 2 deletions app/views/issues/_form_custom_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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' : '' %>
<fieldset class="<%= fieldset_class %>">
<%= 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? %>
<div class="splitcontent" style="<%= div_style %>">
<div class="splitcontentleft">
Expand Down
13 changes: 13 additions & 0 deletions assets/images/icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/stylesheets/custom_fields_groups.css
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 2 additions & 0 deletions config/icon_source.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- name: custom-fields-groups
svg: list-check
29 changes: 10 additions & 19 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/functional/custom_fields_groups_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/integration/layout_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions test/system/fieldset_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 11 additions & 4 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions test/unit/custom_fields_group_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down