Permalink
Browse files

Merge pull request #14170 from kritik/master

there could be more than 10 nested records
Conflicts:
	actionview/CHANGELOG.md
  • Loading branch information...
1 parent 64bbc9e commit 25dd7c9984d1085eaecc2f02bdf6d88ede1c8f12 @senny senny committed Feb 24, 2014
View
@@ -1,3 +1,7 @@
+* Fix label translation for more than 10 nested elements.
+
+ *Vladimir Krylov*
+
* Use a custom route visitor for optimized url generation. Fixes #13349.
*Andrew White*
@@ -36,7 +36,7 @@ def render(&block)
content = @template_object.capture(&block)
else
content = if @content.blank?
- @object_name.gsub!(/\[(.*)_attributes\]\[\d\]/, '.\1')
+ @object_name.gsub!(/\[(.*)_attributes\]\[\d+\]/, '.\1')
method_and_value = tag_value.present? ? "#{@method_name}.#{tag_value}" : @method_name
if object.respond_to?(:to_model)
@@ -2393,6 +2393,18 @@ def test_nested_fields_for_arel_like
assert_dom_equal expected, output_buffer
end
+ def test_nested_fields_label_translation_with_more_than_10_records
+ @post.comments = Array.new(11) { |id| Comment.new(id + 1) }
+
+ I18n.expects(:t).with('post.comments.body', default: [:"comment.body", ''], scope: "helpers.label").times(11).returns "Write body here"
+
+ form_for(@post) do |f|
+ f.fields_for(:comments) do |cf|
+ concat cf.label(:body)
+ end
+ end
+ end
+
def test_nested_fields_for_with_existing_records_on_a_supplied_nested_attributes_collection_different_from_record_one
comments = Array.new(2) { |id| Comment.new(id + 1) }
@post.comments = []

0 comments on commit 25dd7c9

Please sign in to comment.