Merge branch 'master' into rm-custom-error

Conflicts:
	test/form_builder/error_test.rb
This commit is contained in:
Rafael Mendonça França 2014-04-03 18:01:50 -03:00
commit ea679105dc
3 changed files with 17 additions and 3 deletions

View File

@ -6,7 +6,7 @@ module SimpleForm
end
def full_error(wrapper_options = nil)
full_error_text if has_errors?
full_error_text if options[:error] != false && has_errors?
end
def has_errors?
@ -20,7 +20,7 @@ module SimpleForm
end
def full_error_text
"#{html_escape(options[:error_prefix])} #{full_errors.send(error_method)}".lstrip.html_safe
"#{full_errors.send(error_method)}".html_safe
end
def error_method

View File

@ -17,7 +17,7 @@ module SimpleForm
# Provide a fallback if name cannot be found.
def find(name)
super || SimpleForm::Wrappers::Many.new(name, [name])
super || SimpleForm::Wrappers::Many.new(name, [Leaf.new(name)])
end
private

View File

@ -133,6 +133,20 @@ class ErrorTest < ActionView::TestCase
end
end
test 'full error can be disabled' do
swap_wrapper :default, self.custom_wrapper_with_full_error do
with_form_for @user, :company_id, as: :select, full_error: false
assert_no_select 'span.error'
end
end
test 'full error can be disabled setting error to false' do
swap_wrapper :default, self.custom_wrapper_with_full_error do
with_form_for @user, :company_id, as: :select, error: false
assert_no_select 'span.error'
end
end
# CUSTOM ERRORS
test 'input with custom error works' do