Permalink
Browse files

Updated for multiple validators per attribute

  • Loading branch information...
1 parent cc1a75b commit dabae45bba4149047f2da6d6590fbc3d60485dba @bcardarella bcardarella committed Jul 21, 2012
Showing with 4 additions and 4 deletions.
  1. +2 −2 test/action_view/models/post.rb
  2. +2 −2 test/simple_form/cases/test_form_helpers.rb
@@ -16,9 +16,9 @@ def persisted?
def client_side_validation_hash
{
:cost => {
- :presence => {
+ :presence => [{
:message => "can't be blank"
- }
+ }]
}
}
end
@@ -19,7 +19,7 @@ def test_simple_form_for
concat f.input(:cost)
end
- expected = %{<form accept-charset="UTF-8" action="/posts/123" class="simple_form edit_post" data-validate="true" id="edit_post_123" method="post" novalidate="novalidate"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="_method" type="hidden" value="put" /></div><div class="input string required"><label class="string required" for="post_cost"><abbr title="required">*</abbr> Cost</label><input class="string required" data-validate="true" id="post_cost" name="post[cost]" required="required" size="50" type="text" /></div></form><script>//<![CDATA[\nwindow.ClientSideValidations.forms['edit_post_123'] = {"type":"SimpleForm::FormBuilder","error_class":"error","error_tag":"span","wrapper_error_class":"field_with_errors","wrapper_tag":"div","wrapper":"default","validators":{"post[cost]":{"presence":{"message":"can't be blank"}}}};\n//]]></script>}
+ expected = %{<form accept-charset="UTF-8" action="/posts/123" class="simple_form edit_post" data-validate="true" id="edit_post_123" method="post" novalidate="novalidate"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="_method" type="hidden" value="put" /></div><div class="input string required"><label class="string required" for="post_cost"><abbr title="required">*</abbr> Cost</label><input class="string required" data-validate="true" id="post_cost" name="post[cost]" required="required" size="50" type="text" /></div></form><script>//<![CDATA[\nif(window.ClientSideValidations==undefined)window.ClientSideValidations={};if(window.ClientSideValidations.forms==undefined)window.ClientSideValidations.forms={};window.ClientSideValidations.forms['edit_post_123'] = {"type":"SimpleForm::FormBuilder","error_class":"error","error_tag":"span","wrapper_error_class":"field_with_errors","wrapper_tag":"div","wrapper":"default","validators":{"post[cost]":{"presence":[{"message":"can't be blank"}]}}};\n//]]></script>}
assert_equal expected, output_buffer, "\n\n *** If you're running Ruby 1.8 and this test fails is is most likely due to 1.8's lack of insertion order persistence with Hashes ***\n"
end
@@ -28,7 +28,7 @@ def test_input_override
concat f.input(:cost, :validate => false)
end
- expected = %{<form accept-charset="UTF-8" action="/posts/123" class="simple_form edit_post" data-validate="true" id="edit_post_123" method="post" novalidate="novalidate"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="_method" type="hidden" value="put" /></div><div class="input string required"><label class="string required" for="post_cost"><abbr title="required">*</abbr> Cost</label><input class="string required" id="post_cost" name="post[cost]" required="required" size="50" type="text" /></div></form><script>//<![CDATA[\nwindow.ClientSideValidations.forms['edit_post_123'] = {"type":"SimpleForm::FormBuilder","error_class":"error","error_tag":"span","wrapper_error_class":"field_with_errors","wrapper_tag":"div","wrapper":"default","validators":{}};\n//]]></script>}
+ expected = %{<form accept-charset="UTF-8" action="/posts/123" class="simple_form edit_post" data-validate="true" id="edit_post_123" method="post" novalidate="novalidate"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="_method" type="hidden" value="put" /></div><div class="input string required"><label class="string required" for="post_cost"><abbr title="required">*</abbr> Cost</label><input class="string required" id="post_cost" name="post[cost]" required="required" size="50" type="text" /></div></form><script>//<![CDATA[\nif(window.ClientSideValidations==undefined)window.ClientSideValidations={};if(window.ClientSideValidations.forms==undefined)window.ClientSideValidations.forms={};window.ClientSideValidations.forms['edit_post_123'] = {"type":"SimpleForm::FormBuilder","error_class":"error","error_tag":"span","wrapper_error_class":"field_with_errors","wrapper_tag":"div","wrapper":"default","validators":{}};\n//]]></script>}
assert_equal expected, output_buffer, "\n\n *** If you're running Ruby 1.8 and this test fails is is most likely due to 1.8's lack of insertion order persistence with Hashes ***\n"
end

0 comments on commit dabae45

Please sign in to comment.