Hints are assumed html_safe
This commit is contained in:
parent
5f42f0fb6a
commit
ccdcde855b
|
@ -5,7 +5,7 @@ module SimpleForm
|
|||
def hint
|
||||
@hint ||= begin
|
||||
hint = options[:hint]
|
||||
hint.is_a?(String) ? hint : translate(:hints)
|
||||
hint.is_a?(String) ? hint.html_safe : (translate(:hints).html_safe if translate(:hints))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -42,6 +42,12 @@ class HintTest < ActionView::TestCase
|
|||
assert_select 'span#hint.hint.yay'
|
||||
end
|
||||
|
||||
test 'hint should be output as html_safe' do
|
||||
with_hint_for @user, :name, :hint => '<b>Bold</b> and not...'
|
||||
assert_select 'span.hint', 'Bold and not...'
|
||||
end
|
||||
|
||||
|
||||
# Without attribute name
|
||||
|
||||
test 'hint without attribute name' do
|
||||
|
@ -105,6 +111,16 @@ class HintTest < ActionView::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
test 'hint should output translations as html_safe' do
|
||||
store_translations(:en, :simple_form => { :hints => { :user => {
|
||||
:edit => { :name => '<b>This is bold</b> and this is not...' }
|
||||
} } }) do
|
||||
with_hint_for @user, :name
|
||||
assert_select 'span.hint', 'This is bold and this is not...'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# No object
|
||||
|
||||
test 'hint should generate properly when object is not present' do
|
||||
|
|
Loading…
Reference in New Issue