Permalink
Browse files

can use blank collection with grouped_collection input, closes #430

  • Loading branch information...
nashby committed Feb 3, 2012
1 parent f67bdbb commit beb5158d1ff9a24f0a62521b8274c6e6fc0e201c
@@ -19,7 +19,7 @@ def grouped_collection
# Sample collection
def collection
- @collection ||= grouped_collection.first.try(:send, group_method)
+ @collection ||= grouped_collection.first.try(:send, group_method) || []
end
def group_method
@@ -20,6 +20,15 @@ class GroupedCollectionSelectInputTest < ActionView::TestCase
end
end
+ test 'grouped collection accepts empty array collection form' do
+ with_input_for @user, :tag_ids, :grouped_select,
+ :collection => [],
+ :group_method => :last
+
+ assert_select 'select.grouped_select#user_tag_ids'
+ end
+
+
test 'grouped collection accepts proc as collection' do
with_input_for @user, :tag_ids, :grouped_select,
:collection => Proc.new { [['Authors', ['Jose', 'Carlos']], ['General', ['Bob', 'John']]] },

0 comments on commit beb5158

Please sign in to comment.