Merge pull request #447 from edison/master

Escape HTML tags for inline field errors
This commit is contained in:
Rafael Mendonça França 2012-02-16 09:15:25 -08:00
commit 6b069bf9a9
4 changed files with 14 additions and 2 deletions

View File

@ -12,7 +12,7 @@ module SimpleForm
protected
def error_text
"#{options[:error_prefix]} #{errors.send(error_method)}".lstrip
"#{options[:error_prefix]} #{errors.send(error_method)}".lstrip.html_safe
end
def error_method

View File

@ -25,7 +25,7 @@ module SimpleForm
end
def error_message
@message || translate_error_notification
(@message || translate_error_notification).html_safe
end
def error_notification_tag

View File

@ -60,4 +60,10 @@ class ErrorNotificationTest < ActionView::TestCase
assert_select 'div.error_notification'
end
end
test 'error notification should contain HTML tags' do
with_error_notification_for @user, :message => 'Erro encontrado ao criar <b>usuario</b>'
assert_select 'p.error_notification', 'Erro encontrado ao criar usuario'
assert_select 'p.error_notification b', 'usuario'
end
end

View File

@ -73,6 +73,12 @@ class ErrorTest < ActionView::TestCase
assert_no_select 'p.error[error_method]'
end
test 'error should generate an error message with raw HTML tags' do
with_error_for @user, :name, :error_prefix => '<b>Name</b>'
assert_select 'span.error', "Name can't be blank"
assert_select 'span.error b', "Name"
end
# FULL ERRORS
test 'full error should generate an full error tag for the attribute' do