Skip to content

Commit a3d4a1d

Browse files
committed
Update specs and improve compatibility with latest Redmine version
1 parent af2e4d6 commit a3d4a1d

File tree

8 files changed

+44
-15
lines changed

8 files changed

+44
-15
lines changed

.github/workflows/5_1_5.yml renamed to .github/workflows/5_1_9.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
name: Tests 5.1.5
1+
name: Tests 5.1.9
22

33
env:
44
PLUGIN_NAME: redmine_datetime_custom_field
5-
REDMINE_VERSION: 5.1.5
5+
REDMINE_VERSION: 5.1.9
66
RAILS_ENV: test
77

88
on:

.github/workflows/6_0_2.yml renamed to .github/workflows/6_0_6.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
name: Tests 6.0.2
1+
name: Tests 6.0.6
22

33
env:
44
PLUGIN_NAME: redmine_datetime_custom_field
5-
REDMINE_VERSION: 6.0.2
5+
REDMINE_VERSION: 6.0.6
66
RAILS_ENV: test
77

88
on:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ Note that this plugin has a dependency. You have to install this other plugin:
1212

1313
|Plugin branch| Redmine Version | Test Status |
1414
|-------------|-----------------|-------------------|
15-
|master | 6.0.2 | [![6.0.2][1]][5] |
16-
|master | 5.1.5 | [![5.1.5][2]][5] |
15+
|master | 6.0.6 | [![6.0.6][1]][5] |
16+
|master | 5.1.9 | [![5.1.9][2]][5] |
1717
|master | master | [![master][4]][5] |
1818

1919
[1]: https://github.com/nanego/redmine_datetime_custom_field/actions/workflows/6_0_2.yml/badge.svg

lib/redmine_datetime_custom_field/application_helper_patch.rb

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,29 @@
66

77
module RedmineDatetimeCustomField
88
module ApplicationHelperPatch
9-
def format_object(object, html = true, &block)
10-
if (object.class.name == 'CustomValue' || object.class.name == 'CustomFieldValue') && object.custom_field
9+
def format_object(object, *args, &block)
10+
11+
if (object.is_a?(CustomValue) || object.is_a?(CustomFieldValue)) && object.custom_field.present?
1112
return "" unless object.customized&.visible?
12-
f = object.custom_field.format.formatted_custom_value(self, object, html)
13+
14+
options =
15+
if args.first.is_a?(Hash)
16+
args.first
17+
elsif !args.empty?
18+
# Support the old syntax `format_object(object, html_flag)`
19+
# TODO: Display a deprecation warning in a future version, then remove this
20+
{:html => args.first}
21+
else
22+
{}
23+
end
24+
html = options.fetch(:html, true)
25+
26+
if self.respond_to?(:simple_format)
27+
f = object.custom_field.format.formatted_custom_value(self, object, html: html)
28+
else
29+
return super
30+
end
31+
1332
if f.nil? || f.is_a?(String)
1433
f
1534
else

spec/checksums_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require 'spec_helper'
2+
3+
describe "Checksums" do
4+
def assert_checksum(expected, filename)
5+
filepath = Rails.root.join(filename)
6+
checksum = Digest::MD5.hexdigest(File.read(filepath))
7+
assert checksum.in?(Array(expected)), "Bad checksum for file: #{filename}, local version should be reviewed: checksum=#{checksum}, expected=#{Array(expected).join(" or ")}"
8+
end
9+
10+
it "checks core file application_helper checksums" do
11+
# several methods are overridden and should be reviewed if the checksum change
12+
# version 6.0.6 is OK
13+
assert_checksum %w"ba954d7d5c77ecd13256f2bef721db73", "app/helpers/application_helper.rb"
14+
end
15+
end

spec/helpers/application_helper_patch_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require File.dirname(__FILE__) + '/../spec_helper'
1+
require 'spec_helper'
22
require_relative '../../lib/redmine_datetime_custom_field/application_helper_patch'
33

44
describe ApplicationHelper, type: :helper do

spec/spec_helper.rb

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/test_helper.rb

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)