1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-01-20 06:12:56 +00:00

Support of default Active Record (I18n) transliteration paths (#22383).

Patch by Ivan Zabrovskiy.

git-svn-id: http://svn.redmine.org/redmine/trunk@15330 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2016-04-12 18:54:28 +00:00
parent dae1e6ab21
commit 223141a20b
2 changed files with 18 additions and 4 deletions

View File

@ -4,9 +4,23 @@ module ActiveRecord
class Base
include Redmine::I18n
# Translate attribute names for validation errors display
def self.human_attribute_name(attr, *args)
attr = attr.to_s.sub(/_id$/, '').sub(/^.+\./, '')
l("field_#{name.underscore.gsub('/', '_')}_#{attr}", :default => ["field_#{attr}".to_sym, attr])
def self.human_attribute_name(attr, options = {})
prepared_attr = attr.to_s.sub(/_id$/, '').sub(/^.+\./, '')
redmine_default =
[
:"field_#{name.underscore.gsub('/', '_')}_#{prepared_attr}",
:"field_#{prepared_attr}"
]
if options[:default].present?
options[:default] = [options[:default]] unless options[:default].is_a? Array
options[:default].unshift redmine_default
else
options[:default] = redmine_default
end
super
end
end

View File

@ -57,7 +57,7 @@ class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base
end
assert_response :unprocessable_entity
assert_select 'errors error', :text => /relation_type is not included in the list/
assert_select 'errors error', :text => /Relation type is not included in the list/
end
test "GET /relations/:id.xml should return the relation" do