Project

General

Profile

Feature #38231 » limit-year-to-4-digits-v2.patch

Go MAEDA, 2023-03-29 06:26

View differences:

config/initializers/10-patches.rb
end
end
module FormHelper
alias :date_field_without_max :date_field
def date_field(object_name, method, options = {})
date_field_without_max(object_name, method, options.reverse_merge(max: '9999-12-31'))
end
end
module FormTagHelper
alias :select_tag_without_non_empty_blank_option :select_tag
def select_tag(name, option_tags = nil, options = {})
......
end
select_tag_without_non_empty_blank_option(name, option_tags, options)
end
alias :date_field_tag_without_max :date_field_tag
def date_field_tag(name, value = nil, options = {})
date_field_tag_without_max(name, value, options.reverse_merge(max: '9999-12-31'))
end
end
module FormOptionsHelper
test/unit/initializers/patches_test.rb
class PatchesTest < ActiveSupport::TestCase
include Redmine::I18n
include ActionView::Helpers::FormHelper
def setup
Setting.default_language = 'en'
......
test "ActiveRecord::Base.human_attribute_name should default to humanized value if no translation has been found (useful for custom fields)" do
assert_equal 'Patch name', ActiveRecord::Base.human_attribute_name('Patch name')
end
test 'ActionView::Helpers::FormHelper.date_field should add max=9999-12-31 to limit year value to 4 digits' do
assert_include 'max="9999-12-31"', date_field('issue', 'start_date')
end
test 'ActionView::Helpers::FormTagHelper.date_field_tag should add max=9999-12-31 to limit year value to 4 digits' do
assert_include 'max="9999-12-31"', date_field_tag('start_date')
end
end
(2-2/2)