Rename previous commit to wrapper_error_class and add a configuration test.

This commit is contained in:
José Valim 2010-05-24 22:38:38 +02:00
parent 7ce457ca51
commit 8cb2092c40
5 changed files with 14 additions and 4 deletions

View File

@ -1,3 +1,6 @@
* enhancements
* Add error class on wrappers (by github.com/jduff)
== 1.2.0
* deprecation

View File

@ -17,7 +17,7 @@ SimpleForm.setup do |config|
# config.wrapper_tag = :div
# CSS class to add to the wrapper if the field has errors
# config.wrapper_errors_class = :fieldWithErrors
# config.wrapper_error_class = :fieldWithErrors
# How the label text should be generated altogether with the required text.
# config.label_text = lambda { |label, required| "#{required} #{label}" }

View File

@ -33,8 +33,8 @@ module SimpleForm
mattr_accessor :wrapper_tag
@@wrapper_tag = :div
mattr_accessor :wrapper_errors_class
@@wrapper_errors_class = :fieldWithErrors
mattr_accessor :wrapper_error_class
@@wrapper_error_class = :fieldWithErrors
# How the label text should be generated altogether with the required text.
mattr_accessor :label_text

View File

@ -14,7 +14,7 @@ module SimpleForm
end
def errors_class
options[:wrapper_errors_class] || SimpleForm.wrapper_errors_class
options[:wrapper_error_class] || SimpleForm.wrapper_error_class
end
def wrapper_html_options

View File

@ -22,4 +22,11 @@ class WrapperTest < ActionView::TestCase
with_error_for @user, :name
assert_select 'div.fieldWithErrors'
end
test 'wrapper should add chosen error class for attribute with errors' do
swap SimpleForm, :wrapper_error_class => "omgError" do
with_error_for @user, :name
assert_select 'div.omgError'
end
end
end