Permalink
Browse files

Merge branch 'master' into rails3

  • Loading branch information...
2 parents 4481341 + 0aa2cc2 commit dd4651c339977f54eb040cd4a657ed537a566812 @yabawock yabawock committed Jul 30, 2010
Showing with 55 additions and 7 deletions.
  1. +7 −1 CHANGELOG
  2. +1 −1 VERSION.yml
  3. +2 −2 formtastic.gemspec
  4. +3 −2 lib/formtastic.rb
  5. +23 −1 spec/inputs/time_input_spec.rb
  6. +19 −0 spec/inputs_spec.rb
View
@@ -8,7 +8,13 @@
* Added compatible install and form helpers (rails3)
* Added support for ActiveModel Validations, thanks to Guillaume Belleguic (rails3)
-1.0.0.beta2 (unreleased)
+1.0.0.beta3
+
+* Added :ignore_date option to time inputs (#308)
+* Fixed inputs_for_nested_attributes returning out of the proc on has_many associated nested models.
+* Fixed with_custom_field_error_proc to use ensure for restoring default field_error_proc and to store it in a local variable instead of in a class variable (nested calls were problematic due to the globalness of class variables)
+
+1.0.0.beta2
* Added default escaping of html entities in labels and hints (#292, #299)
* Added/Fixed that :value_method and :label_method were not being used for simple collections (like Arrays)
View
@@ -2,4 +2,4 @@
:major: 1
:minor: 0
:patch: 0
-:build: beta2
+:build: beta3
View
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = %q{formtastic}
- s.version = "1.0.0.beta2"
+ s.version = "1.0.0.beta3"
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
s.authors = ["Justin French"]
- s.date = %q{2010-07-21}
+ s.date = %q{2010-07-29}
s.description = %q{A Rails form builder plugin/gem with semantically rich and accessible markup}
s.email = %q{justin@indent.com.au}
s.extra_rdoc_files = [
View
@@ -529,13 +529,13 @@ def inputs_for_nested_attributes(*args, &block) #:nodoc:
raise ArgumentError, 'You gave :for option with a block to inputs method, ' <<
'but the block does not accept any argument.' if block.arity <= 0
- Proc.new do |f|
+ lambda do |f|
contents = f.inputs(*args){ block.call(f) }
template.concat(contents) if ::Formtastic::Util.rails3?
contents
end
else
- Proc.new do |f|
+ lambda do |f|
contents = f.inputs(*args)
template.concat(contents) if ::Formtastic::Util.rails3?
contents
@@ -1030,6 +1030,7 @@ def date_or_datetime_input(method, options)
i18n_date_order = ::I18n.t(:order, :scope => [:date])
i18n_date_order = nil unless i18n_date_order.is_a?(Array)
inputs = options.delete(:order) || i18n_date_order || [:year, :month, :day]
+ inputs = [] if options[:ignore_date]
labels = options.delete(:labels) || {}
time_inputs = [:hour, :minute]
@@ -15,7 +15,29 @@
::I18n.backend.reload!
output_buffer.replace ''
end
-
+
+ describe "with :ignore_date" do
+ before do
+ @form = semantic_form_for(@new_post) do |builder|
+ concat(builder.input(:publish_at, :as => :time, :ignore_date => true))
+ end
+ end
+
+ it 'should not have an input for day, month and year' do
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
+ output_buffer.should_not have_tag('#post_publish_at_1i')
+ output_buffer.should_not have_tag('#post_publish_at_2i')
+ output_buffer.should_not have_tag('#post_publish_at_3i')
+ end
+
+ it 'should have an input for hour and minute' do
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
+ output_buffer.should have_tag('#post_publish_at_4i')
+ output_buffer.should have_tag('#post_publish_at_5i')
+ end
+
+ end
+
describe "without seconds" do
before do
@form = semantic_form_for(@new_post) do |builder|
View
@@ -114,6 +114,25 @@
end
+ describe "as a symbol representing a has_many association name" do
+ before do
+ @new_post.stub!(:authors).and_return([@bob, @fred])
+ @new_post.stub!(:authors_attributes=)
+ end
+
+ it 'should nest the inputs with a name input for each item' do
+ form = semantic_form_for(@new_post) do |post|
+ post.inputs :for => :authors do |author|
+ concat(author.input(:login))
+ end
+ end
+
+ output_buffer.concat(form) if Formtastic::Util.rails3?
+ output_buffer.should have_tag("form input[@name='post[authors_attributes][0][login]']")
+ output_buffer.should have_tag("form input[@name='post[authors_attributes][1][login]']")
+ end
+ end
+
describe 'as an array containing the a symbole for the association name and the associated object' do
it 'should nest the inputs with an _attributes suffix on the association name' do

0 comments on commit dd4651c

Please sign in to comment.