Permalink
Browse files

Support SimpleForm 2.0.0

  • Loading branch information...
1 parent 88513a7 commit e6aefabda2cccc7346ad4cfc4ded8ff12895e0eb @bcardarella bcardarella committed Jul 9, 2012
@@ -13,8 +13,8 @@ Gem::Specification.new do |gem|
gem.require_paths = ['lib']
gem.version = ClientSideValidations::SimpleForm::VERSION
- gem.add_dependency 'client_side_validations', '~> 3.2.0.beta.1'
- gem.add_dependency 'simple_form', '~> 1.5.0'
+ gem.add_dependency 'client_side_validations', '~> 3.2.0.beta.4'
+ gem.add_dependency 'simple_form', '~> 2.0.0'
gem.add_development_dependency 'rails', '~> 3.2.0'
gem.add_development_dependency 'mocha'
@@ -4,13 +4,13 @@ module FormBuilder
def self.included(base)
base.class_eval do
- def self.client_side_form_settings(options, form_helper)
+ def client_side_form_settings(options, form_helper)
{
- :type => self.to_s,
- :error_class => ::SimpleForm.error_class,
- :error_tag => ::SimpleForm.error_tag,
- :wrapper_error_class => ::SimpleForm.wrapper_error_class,
- :wrapper_tag => ::SimpleForm.wrapper_tag
+ :type => self.class.to_s,
+ :error_class => wrapper.find(:error).defaults[:class].first,
+ :error_tag => wrapper.find(:error).defaults[:tag],
+ :wrapper_error_class => wrapper.defaults[:error_class],
+ :wrapper_tag => wrapper.defaults[:tag]
}
end
alias_method_chain :input, :client_side_validations
@@ -1,5 +1,5 @@
module ClientSideValidations
module SimpleForm
- VERSION = '1.5.0.beta.3'
+ VERSION = '2.0.0.beta.1'
end
end
View
@@ -4,6 +4,7 @@
require 'rails'
require 'test/unit'
require 'mocha'
+
if RUBY_VERSION >= '1.9.3'
require 'debugger'
end
@@ -9,7 +9,8 @@ def test_client_side_form_js_hash
:wrapper_error_class => :field_with_errors,
:wrapper_tag => :div
}
- assert_equal expected, SimpleForm::FormBuilder.client_side_form_settings(nil, nil)
+ builder = SimpleForm::FormBuilder.new(:user, nil, {}, {}, Proc.new {})
+ assert_equal expected, builder.client_side_form_settings(nil, nil)
end
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 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>window.ClientSideValidations.forms['edit_post_123'] = {"type":"SimpleForm::FormBuilder","error_class":"error","error_tag":"span","wrapper_error_class":"field_with_errors","wrapper_tag":"div","validators":{"post[cost]":{"presence":{"message":"can't be blank"}}}};</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[\nwindow.ClientSideValidations.forms['edit_post_123'] = {"type":"SimpleForm::FormBuilder","error_class":"error","error_tag":"span","wrapper_error_class":"field_with_errors","wrapper_tag":"div","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 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>window.ClientSideValidations.forms['edit_post_123'] = {"type":"SimpleForm::FormBuilder","error_class":"error","error_tag":"span","wrapper_error_class":"field_with_errors","wrapper_tag":"div","validators":{}};</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[\nwindow.ClientSideValidations.forms['edit_post_123'] = {"type":"SimpleForm::FormBuilder","error_class":"error","error_tag":"span","wrapper_error_class":"field_with_errors","wrapper_tag":"div","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
@@ -1,13 +1,14 @@
/*
- Client Side Validations - SimpleForm - v1.5.0.beta.3
+ Client Side Validations - SimpleForm - v2.0.0.beta.1
https://github.com/dockyard/client_side_validations-simple_form
Copyright (c) 2012 DockYard, LLC
Licensed under the MIT license
http://www.opensource.org/licenses/mit-license.php
*/
+
(function() {
ClientSideValidations.formBuilders['SimpleForm::FormBuilder'] = {

0 comments on commit e6aefab

Please sign in to comment.