diff --git a/lib/simple_form/components/errors.rb b/lib/simple_form/components/errors.rb index b416bce2..74d6f5ee 100644 --- a/lib/simple_form/components/errors.rb +++ b/lib/simple_form/components/errors.rb @@ -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 diff --git a/lib/simple_form/error_notification.rb b/lib/simple_form/error_notification.rb index a5ee84f3..0cd0c63d 100644 --- a/lib/simple_form/error_notification.rb +++ b/lib/simple_form/error_notification.rb @@ -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 diff --git a/test/form_builder/error_notification_test.rb b/test/form_builder/error_notification_test.rb index 2fb1cd36..d71d3a81 100644 --- a/test/form_builder/error_notification_test.rb +++ b/test/form_builder/error_notification_test.rb @@ -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 usuario' + assert_select 'p.error_notification', 'Erro encontrado ao criar usuario' + assert_select 'p.error_notification b', 'usuario' + end end diff --git a/test/form_builder/error_test.rb b/test/form_builder/error_test.rb index ecbe8827..4a370c3d 100644 --- a/test/form_builder/error_test.rb +++ b/test/form_builder/error_test.rb @@ -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 => 'Name' + 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