You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow :value_method and :text_method for collection_check_boxes and collection_radio_buttons to be any Object that responds to , e.g. a Proc or lambda, to match the same functionality as provided by the corresponding Rails form helper methods.
Ensure that a single String checked value does not perform an include? check by converting checked value(s) to an Array.
test'collection_radio_buttons renders label defined by Proc correctly'do
69
+
collection=[Address.new(id: 1,street: 'Foobar')]
70
+
expected=%{<div class="form-group"><label class="control-label" for="user_misc">This is a radio button collection</label><div class="radio"><label for="user_misc_1"><input id="user_misc_1" name="user[misc]" type="radio" value="1" /> rabooF</label></div><span class="help-block">With a help!</span></div>}
71
+
72
+
assert_equalexpected,@builder.collection_radio_buttons(:misc,collection,:id,Proc.new{ |a| a.street.reverse},label: 'This is a radio button collection',help: 'With a help!')
73
+
end
74
+
75
+
test'collection_radio_buttons renders value defined by Proc correctly'do
76
+
collection=[Address.new(id: 1,street: 'Foobar')]
77
+
expected=%{<div class="form-group"><label class="control-label" for="user_misc">This is a radio button collection</label><div class="radio"><label for="user_misc_address_1"><input id="user_misc_address_1" name="user[misc]" type="radio" value="address_1" /> Foobar</label></div><span class="help-block">With a help!</span></div>}
78
+
79
+
assert_equalexpected,@builder.collection_radio_buttons(:misc,collection,Proc.new{ |a| "address_#{a.id}"},:street,label: 'This is a radio button collection',help: 'With a help!')
80
+
end
81
+
82
+
test'collection_radio_buttons renders multiple radios with label defined by Proc correctly'do
test'collection_radio_buttons renders label defined by lambda correctly'do
97
+
collection=[Address.new(id: 1,street: 'Foobar')]
98
+
expected=%{<div class="form-group"><label class="control-label" for="user_misc">This is a radio button collection</label><div class="radio"><label for="user_misc_1"><input id="user_misc_1" name="user[misc]" type="radio" value="1" /> rabooF</label></div><span class="help-block">With a help!</span></div>}
99
+
100
+
assert_equalexpected,@builder.collection_radio_buttons(:misc,collection,:id,lambda{ |a| a.street.reverse},label: 'This is a radio button collection',help: 'With a help!')
101
+
end
102
+
103
+
test'collection_radio_buttons renders value defined by lambda correctly'do
104
+
collection=[Address.new(id: 1,street: 'Foobar')]
105
+
expected=%{<div class="form-group"><label class="control-label" for="user_misc">This is a radio button collection</label><div class="radio"><label for="user_misc_address_1"><input id="user_misc_address_1" name="user[misc]" type="radio" value="address_1" /> Foobar</label></div><span class="help-block">With a help!</span></div>}
106
+
107
+
assert_equalexpected,@builder.collection_radio_buttons(:misc,collection,lambda{ |a| "address_#{a.id}"},:street,label: 'This is a radio button collection',help: 'With a help!')
108
+
end
109
+
110
+
test'collection_radio_buttons renders multiple radios with label defined by lambda correctly'do
0 commit comments