From 645dd5257d8bcce39330621b389c50778366d9fa Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Fri, 26 Oct 2012 01:47:39 -0200 Subject: [PATCH] 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. --- lib/simple_form/components/hints.rb | 2 +- test/form_builder/general_test.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/simple_form/components/hints.rb b/lib/simple_form/components/hints.rb index bdca11a6..a95f9c5e 100644 --- a/lib/simple_form/components/hints.rb +++ b/lib/simple_form/components/hints.rb @@ -11,7 +11,7 @@ module SimpleForm end def has_hint? - hint.present? + options[:hint] != false && hint.present? end end end diff --git a/test/form_builder/general_test.rb b/test/form_builder/general_test.rb index dc9c92ff..5ac35ec0 100644 --- a/test/form_builder/general_test.rb +++ b/test/form_builder/general_test.rb @@ -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