Permalink
Browse files

Merge branch 'master' into rails3

Conflicts:
	CHANGELOG
	spec/inputs/radio_input_spec.rb
	spec/inputs/string_input_spec.rb
  • Loading branch information...
2 parents c768a99 + cb9e146 commit 5c88e8e0d1b92a5ca5f9945dea7a9456cec05c9b @mjonuschat mjonuschat committed Jun 9, 2010
Showing with 121 additions and 33 deletions.
  1. +7 −0 CHANGELOG
  2. +4 −4 VERSION.yml
  3. +3 −3 formtastic.gemspec
  4. +16 −5 lib/formtastic.rb
  5. +22 −2 spec/inputs/check_boxes_input_spec.rb
  6. +34 −1 spec/inputs/radio_input_spec.rb
  7. +35 −18 spec/inputs/string_input_spec.rb
View
@@ -8,6 +8,13 @@
* Added compatible install and form helpers (rails3)
* Added support for ActiveModel Validations, thanks to Guillaume Belleguic (rails3)
+1.0.0.beta
+
+* Fixed :radio and :check_boxes inputs so that the legend no longer includes a <label> with a `for` attribute pointing to an input that doesn't exist (#253)
+* Fixed that some inputs had invalid 'find_options' attribute (#262)
+* Fixed that we were calling html_safe! when it was not always available
+* Added the ability for :input_html to now accept an option of :size => nil, to exclude the :size attribute altogether (#267)
+
0.9.10
* Fixed i18n incompatibility with Rails 2.3.8 by reverting two i18n patches pulled in from the rails3 branch
View
@@ -1,5 +1,5 @@
---
-:major: 0
-:minor: 9
-:build:
-:patch: 10
+:major: 1
+:minor: 0
+:patch: 0
+:build: beta
View
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = %q{formtastic}
- s.version = "0.9.10"
+ s.version = "1.0.0.beta"
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ 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-05-26}
+ s.date = %q{2010-06-07}
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
@@ -541,7 +541,7 @@ def inputs_for_nested_attributes(*args, &block) #:nodoc:
#
def strip_formtastic_options(options) #:nodoc:
options.except(:value_method, :label_method, :collection, :required, :label,
- :as, :hint, :input_html, :label_html, :value_as_class)
+ :as, :hint, :input_html, :label_html, :value_as_class, :find_options)
end
# Determins if the attribute (eg :title) should be considered required or not.
@@ -896,8 +896,13 @@ def radio_input(method, options)
li_options = value_as_class ? { :class => [method.to_s.singularize, value.to_s.downcase].join('_') } : {}
template.content_tag(:li, Formtastic::Util.html_safe(li_content), li_options)
end
-
- field_set_and_list_wrapping_for_method(method, options, list_item_content)
+
+ template.content_tag(:fieldset,
+ template.content_tag(:legend,
+ template.label_tag(nil, localized_string(method, method, :label) || humanized_attribute_name(method), :for => nil), :class => :label
+ ) <<
+ template.content_tag(:ol, list_item_content)
+ )
end
alias :boolean_radio_input :radio_input
@@ -1163,7 +1168,12 @@ def check_boxes_input(method, options)
template.content_tag(:li, Formtastic::Util.html_safe(li_content), li_options)
end
- field_set_and_list_wrapping_for_method(method, options, list_item_content)
+ template.content_tag(:fieldset,
+ template.content_tag(:legend,
+ template.label_tag(nil, localized_string(method, method, :label) || humanized_attribute_name(method), :for => nil), :class => :label
+ ) <<
+ template.content_tag(:ol, list_item_content)
+ )
end
# Outputs a country select input, wrapping around a regular country_select helper.
@@ -1542,7 +1552,8 @@ def default_string_options(method, type) #:nodoc:
elsif type == :numeric || column.nil? || column.limit.nil?
{ :size => @@default_text_field_size }
else
- { :maxlength => column.limit, :size => [column.limit, @@default_text_field_size].min }
+ { :maxlength => column.limit,
+ :size => @@default_text_field_size && [column.limit, @@default_text_field_size].min }
end
end
@@ -250,10 +250,30 @@
end
end
+
+ describe "with i18n of the legend label" do
+
+ before do
+ ::I18n.backend.store_translations :en, :formtastic => { :labels => { :post => { :authors => "Translated!" }}}
+
+ @new_post.stub!(:author_ids).and_return(nil)
+ @form = semantic_form_for(@new_post) do |builder|
+ concat(builder.input(:authors, :as => :check_boxes))
+ end
+ end
+
+ after do
+ ::I18n.backend.reload!
+ end
+ it "should do foo" do
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
+ output_buffer.should have_tag("legend.label label", /Translated/)
+ end
+
+ end
+
end
-
-
end
@@ -31,7 +31,7 @@
it 'should not link the label within the legend to any input' do
output_buffer.concat(@form) if Formtastic::Util.rails3?
- output_buffer.should_not have_tag('form li fieldset legend label[@for^="post_author_id_"]')
+ output_buffer.should_not have_tag('form li fieldset legend label[@for]')
end
it 'should generate an ordered list with a list item for each choice' do
@@ -84,6 +84,17 @@
output_buffer.concat(form) if Formtastic::Util.rails3?
output_buffer.should have_tag("form li fieldset ol li label input[@checked='checked']")
end
+
+ it "should not contain invalid HTML attributes" do
+
+ form = semantic_form_for(@new_post) do |builder|
+ concat(builder.input(:author, :as => :radio))
+ end
+
+ output_buffer.concat(form) if Formtastic::Util.rails3?
+ output_buffer.should_not have_tag("form li fieldset ol li input[@find_options]")
+ end
+
end
describe 'and no object is given' do
@@ -165,5 +176,27 @@
end
end
+
+ describe "with i18n of the legend label" do
+
+ before do
+ ::I18n.backend.store_translations :en, :formtastic => { :labels => { :post => { :authors => "Translated!" }}}
+
+ @new_post.stub!(:author_ids).and_return(nil)
+ @form = semantic_form_for(@new_post) do |builder|
+ concat(builder.input(:authors, :as => :radio))
+ end
+ end
+
+ after do
+ ::I18n.backend.reload!
+ end
+
+ it "should do foo" do
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
+ output_buffer.should have_tag("legend.label label", /Translated/)
+ end
+
+ end
end
@@ -8,26 +8,30 @@
before do
@output_buffer = ''
mock_everything
-
- @form = semantic_form_for(@new_post) do |builder|
- concat(builder.input(:title, :as => :string))
+ end
+
+ describe "when object is provided" do
+ before do
+ @form = semantic_form_for(@new_post) do |builder|
+ concat(builder.input(:title, :as => :string))
+ end
end
+
+ it_should_have_input_wrapper_with_class(:string)
+ it_should_have_input_wrapper_with_id("post_title_input")
+ it_should_have_label_with_text(/Title/)
+ it_should_have_label_for("post_title")
+ it_should_have_input_with_id("post_title")
+ it_should_have_input_with_type(:text)
+ it_should_have_input_with_name("post[title]")
+ it_should_have_maxlength_matching_column_limit
+ it_should_use_default_text_field_size_for_columns_longer_than_default_text_field_size(:string)
+ it_should_use_column_size_for_columns_shorter_than_default_text_field_size(:string)
+ it_should_use_default_text_field_size_when_method_has_no_database_column(:string)
+ it_should_apply_custom_input_attributes_when_input_html_provided(:string)
+ it_should_apply_custom_for_to_label_when_input_html_id_provided(:string)
+ it_should_apply_error_logic_for_input_type(:string)
end
-
- it_should_have_input_wrapper_with_class(:string)
- it_should_have_input_wrapper_with_id("post_title_input")
- it_should_have_label_with_text(/Title/)
- it_should_have_label_for("post_title")
- it_should_have_input_with_id("post_title")
- it_should_have_input_with_type(:text)
- it_should_have_input_with_name("post[title]")
- it_should_have_maxlength_matching_column_limit
- it_should_use_default_text_field_size_for_columns_longer_than_default_text_field_size(:string)
- it_should_use_column_size_for_columns_shorter_than_default_text_field_size(:string)
- it_should_use_default_text_field_size_when_method_has_no_database_column(:string)
- it_should_apply_custom_input_attributes_when_input_html_provided(:string)
- it_should_apply_custom_for_to_label_when_input_html_id_provided(:string)
- it_should_apply_error_logic_for_input_type(:string)
describe "when no object is provided" do
before do
@@ -43,5 +47,18 @@
it_should_have_input_with_name("project[title]")
end
+ describe "when size is nil" do
+ before do
+ @form = semantic_form_for(:project, :url => 'http://test.host/') do |builder|
+ concat(builder.input(:title, :as => :string, :input_html => {:size => nil}))
+ end
+ end
+
+ it "should have no size attribute" do
+ output_buffer.concat(@form) if Formtastic::Util.rails3?
+ output_buffer.should_not have_tag("input[@size]")
+ end
+ end
+
end

0 comments on commit 5c88e8e

Please sign in to comment.