Skip to content

Commit

Permalink
properly fix the test in #1882
Browse files Browse the repository at this point in the history
  • Loading branch information
ujifgc committed Oct 12, 2015
1 parent 7baf2ca commit 2783092
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions padrino-helpers/lib/padrino-helpers/form_helpers/options.rb
Expand Up @@ -57,9 +57,9 @@ def option_is_selected?(value, caption, selected_values)
def options_for_select(option_items, state = {})
return [] if option_items.blank?
option_items.map do |caption, value, attributes|
html_attributes = { :value => value ||= caption }.merge(attributes||{})
html_attributes[:selected] ||= option_is_selected?(value, caption, state[:selected])
html_attributes[:disabled] ||= option_is_selected?(value, caption, state[:disabled])
html_attributes = { :value => value || caption }.merge(attributes||{})
html_attributes[:selected] ||= option_is_selected?(html_attributes[:value], caption, state[:selected])
html_attributes[:disabled] ||= option_is_selected?(html_attributes[:value], caption, state[:disabled])
content_tag(:option, caption, html_attributes)
end
end
Expand Down
4 changes: 2 additions & 2 deletions padrino-helpers/test/test_form_helpers.rb
Expand Up @@ -781,8 +781,8 @@ def protect_from_csrf; false; end
end

it 'should display selected options falling back to checking content' do
options = [['one'], ['two'], ['three', 'three']]
actual_html = select_tag(:number, :options => options, :selected => 'one').gsub!(/value="(one|two)"/, '').html_safe
options = [['one', nil, :value => nil], ['two', nil, :value => nil], ['three', 'three']]
actual_html = select_tag(:number, :options => options, :selected => 'one')
assert_has_tag('select option', :selected => 'selected', :count => 1) { actual_html }
assert_has_tag('select option', :content => 'one', :selected => 'selected') { actual_html }
end
Expand Down

0 comments on commit 2783092

Please sign in to comment.