Do not lookup for hints if it was explicitly given false

After #405 we added hint classes for the wrappers, but this has forced the
loading of the hint text doing I18n lookups, even though it was explicitly
given false. This checks for the option in #has_hint?, avoiding the lookup
in such cases.

This issues has been caught after #627 and some further investigation,
thanks to @shwoodard.
This commit is contained in:
Carlos Antonio da Silva 2012-10-26 01:47:39 -02:00
parent 120c364f7d
commit 645dd5257d
2 changed files with 3 additions and 1 deletions

View File

@ -11,7 +11,7 @@ module SimpleForm
end
def has_hint?
hint.present?
options[:hint] != false && hint.present?
end
end
end

View File

@ -264,6 +264,8 @@ class FormBuilderTest < ActionView::TestCase
test 'builder should be able to disable a hint even if it exists in i18n' do
store_translations(:en, :simple_form => { :hints => { :name => 'Hint test' } }) do
SimpleForm::Inputs::Base.any_instance.expects(:hint).never
with_form_for @user, :name, :hint => false
assert_no_select 'span.hint'
end