Skip to content

Commit 2f5d481

Browse files
Expand collection select input test with multiple disabled options
Improve test descriptions for disabled select / options on collection select input.
1 parent a12f4b7 commit 2f5d481

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

test/inputs/collection_select_input_test.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,22 +220,30 @@ class CollectionSelectInputTest < ActionView::TestCase
220220
assert_select 'select option[value="2"]', 'Carlos'
221221
end
222222

223-
test 'input disables all options when the entire select is disabled' do
223+
test 'input disables the entire select and no specific options when given `true`' do
224224
with_input_for @user, :description, :select, collection: %w[Jose Carlos], disabled: true
225225
assert_no_select 'select option[value=Jose][disabled=disabled]', 'Jose'
226226
assert_no_select 'select option[value=Carlos][disabled=disabled]', 'Carlos'
227227
assert_select 'select[disabled=disabled]'
228228
assert_select 'div.disabled'
229229
end
230230

231-
test 'input disables only specific options when individual options are disabled' do
231+
test 'input allows disabling only a single given option' do
232232
with_input_for @user, :description, :select, collection: %w[Jose Carlos], disabled: 'Jose'
233233
assert_select 'select option[value=Jose][disabled=disabled]', 'Jose'
234234
assert_no_select 'select option[value=Carlos][disabled=disabled]', 'Carlos'
235235
assert_no_select 'select[disabled=disabled]'
236236
assert_no_select 'div.disabled'
237237
end
238238

239+
test 'input allows disabling multiple given options' do
240+
with_input_for @user, :description, :select, collection: %w[Jose Carlos], disabled: %w[Jose Carlos]
241+
assert_select 'select option[value=Jose][disabled=disabled]', 'Jose'
242+
assert_select 'select option[value=Carlos][disabled=disabled]', 'Carlos'
243+
assert_no_select 'select[disabled=disabled]'
244+
assert_no_select 'div.disabled'
245+
end
246+
239247
test 'input allows overriding label and value method using a lambda for collection selects' do
240248
with_input_for @user, :name, :select,
241249
collection: %w[Jose Carlos],

0 commit comments

Comments
 (0)