Skip to content

Commit

Permalink
Fixes: 293 Hint lookup fails when an attribute and model have the sam…
Browse files Browse the repository at this point in the history
…e name

Added fix in inline_hints_for to see a hash as a blank entry.
Added spec to test this failure.
  • Loading branch information
Daan Oosterveld authored and mjonuschat committed Jun 30, 2010
1 parent 49c4418 commit 1c1ba8d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/formtastic.rb
Expand Up @@ -1223,7 +1223,7 @@ def inline_input_for(method, options)
#
def inline_hints_for(method, options) #:nodoc:
options[:hint] = localized_string(method, options[:hint], :hint)
return if options[:hint].blank?
return if options[:hint].blank? or options[:hint].kind_of? Hash
template.content_tag(:p, Formtastic::Util.html_safe(options[:hint]), :class => 'inline-hints')
end

Expand Down
17 changes: 17 additions & 0 deletions spec/input_spec.rb
Expand Up @@ -571,6 +571,23 @@ def should_be_required(options)
end
end

describe 'when localized hint (I18n) is a model with attribute hints' do
it "should see the provided hash as a blank entry" do
::I18n.backend.store_translations :en,
:formtastic => {
:hints => {
:title => { # movie title
:summary => @localized_hint_text # summary of movie
}
}
}
semantic_form_for(@new_post) do |builder|
concat(builder.input(:title, :hint => true))
end
output_buffer.should_not have_tag('form li p.inline-hints', @localized_hint_text)
end
end

describe 'when localized hint (I18n) is not provided' do
it 'should not render a hint paragraph' do
semantic_form_for(@new_post) do |builder|
Expand Down

0 comments on commit 1c1ba8d

Please sign in to comment.