diff options
Diffstat (limited to 'actionview/test')
-rw-r--r-- | actionview/test/actionpack/controller/layout_test.rb | 14 | ||||
-rw-r--r-- | actionview/test/template/form_helper_test.rb | 17 | ||||
-rw-r--r-- | actionview/test/template/translation_helper_test.rb | 5 |
3 files changed, 36 insertions, 0 deletions
diff --git a/actionview/test/actionpack/controller/layout_test.rb b/actionview/test/actionpack/controller/layout_test.rb index 7b8a83e2fe..64ab125637 100644 --- a/actionview/test/actionpack/controller/layout_test.rb +++ b/actionview/test/actionpack/controller/layout_test.rb @@ -122,6 +122,14 @@ class PrependsViewPathController < LayoutTest end end +class ParentController < LayoutTest + layout 'item' +end + +class ChildController < ParentController + layout 'layout_test', only: :hello +end + class OnlyLayoutController < LayoutTest layout 'item', :only => "hello" end @@ -225,6 +233,12 @@ class LayoutSetInResponseTest < ActionController::TestCase get :hello assert_equal "layout_test.erb hello.erb", @response.body.strip end + + def test_respect_to_parent_layout + @controller = ChildController.new + get :goodbye + assert_template :layout => "layouts/item" + end end class SetsNonExistentLayoutFile < LayoutTest diff --git a/actionview/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb index 4e336bea63..5c55b154d3 100644 --- a/actionview/test/template/form_helper_test.rb +++ b/actionview/test/template/form_helper_test.rb @@ -2878,6 +2878,23 @@ class FormHelperTest < ActionView::TestCase assert_dom_equal expected, output_buffer end + def test_nested_fields_for_with_child_index_as_lambda_option_override_on_a_nested_attributes_collection_association + @post.comments = [] + + form_for(@post) do |f| + concat f.fields_for(:comments, Comment.new(321), child_index: -> { 'abc' } ) { |cf| + concat cf.text_field(:name) + } + end + + expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + '<input id="post_comments_attributes_abc_name" name="post[comments_attributes][abc][name]" type="text" value="comment #321" />' + + '<input id="post_comments_attributes_abc_id" name="post[comments_attributes][abc][id]" type="hidden" value="321" />' + end + + assert_dom_equal expected, output_buffer + end + class FakeAssociationProxy def to_ary [1, 2, 3] diff --git a/actionview/test/template/translation_helper_test.rb b/actionview/test/template/translation_helper_test.rb index c4daaae221..df096b3c3a 100644 --- a/actionview/test/template/translation_helper_test.rb +++ b/actionview/test/template/translation_helper_test.rb @@ -195,6 +195,11 @@ class TranslationHelperTest < ActiveSupport::TestCase assert_equal 'A Generic String', translation end + def test_translate_with_array_of_array_default + translation = translate(:'translations.missing', default: [[]]) + assert_equal [], translation + end + def test_translate_does_not_change_options options = {} translate(:'translations.missing', options) |