From 7cbedde3de8501946fb85e5e8a7ecb767fb5c0ff Mon Sep 17 00:00:00 2001 From: Felipe Renan Date: Thu, 17 Jan 2019 16:04:38 -0200 Subject: [PATCH] Add tests to cover multiple attribute for grouped select in associations Also, updates the CHANGELOG.md. --- CHANGELOG.md | 1 + test/form_builder/association_test.rb | 6 ++++++ test/support/models.rb | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e43d185..218780a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Allow custom error on forms without model. [@victorperez](https://github.com/victorperez) * Do not support Ruby < 2.3 anymore. [@gssbzn](https://github.com/gssbzn) * Add color input type. [@gssbzn](https://github.com/gssbzn) +* Set multiple attribute for grouped selects also. [@ollym](https://github.com/ollym) ### Bug fix * Improve disabled option to input_field. [@betelgeuse](https://github.com/betelgeuse) diff --git a/test/form_builder/association_test.rb b/test/form_builder/association_test.rb index 7ce821bf..369d2e08 100644 --- a/test/form_builder/association_test.rb +++ b/test/form_builder/association_test.rb @@ -243,4 +243,10 @@ class AssociationTest < ActionView::TestCase assert_equal({ as: :check_boxes, collection_wrapper_tag: :ul, item_wrapper_tag: :li }, options) end + + test 'builder with group select considers multiple select by default' do + with_association_for @user, :tags, as: :grouped_select, group_method: :group_method + + assert_select 'select[multiple="multiple"].grouped_select' + end end diff --git a/test/support/models.rb b/test/support/models.rb index 28619767..da25b967 100644 --- a/test/support/models.rb +++ b/test/support/models.rb @@ -76,7 +76,11 @@ Friend = Struct.new(:id, :name) do end end -class Tag < Company; end +class Tag < Company + def group_method + ["category-1"] + end +end TagGroup = Struct.new(:id, :name, :tags)