Permalink
Browse files

make tests pass on ruby 1.9.2

  • Loading branch information...
1 parent 1551fc1 commit 736df6f3b975cdd0ef543a9b8bdf955052f7e963 @morgoth morgoth committed with josevalim Jun 17, 2010
@@ -3,7 +3,7 @@
class BuilderTest < ActionView::TestCase
# COLLECTION RADIO
test 'collection radio accepts a collection and generate inputs from value method' do
- concat(form_for @user do |f|
+ concat(form_for(@user) do |f|
concat f.collection_radio :active, [true, false], :to_s, :to_s
end)
@@ -12,7 +12,7 @@ class BuilderTest < ActionView::TestCase
end
test 'collection radio accepts a collection and generate inputs from label method' do
- concat(form_for @user do |f|
+ concat(form_for(@user) do |f|
concat f.collection_radio :active, [true, false], :to_s, :to_s
end)
@@ -21,7 +21,7 @@ class BuilderTest < ActionView::TestCase
end
test 'collection radio accepts checked item' do
- concat(form_for @user do |f|
+ concat(form_for(@user) do |f|
concat f.collection_radio :active, [[1, true], [0, false]], :last, :first, :checked => true
end)
@@ -31,7 +31,7 @@ class BuilderTest < ActionView::TestCase
test 'collection radio accepts multiple disabled items' do
collection = [[1, true], [0, false], [2, 'other']]
- concat(form_for @user do |f|
+ concat(form_for(@user) do |f|
concat f.collection_radio :active, collection, :last, :first, :disabled => [true, false]
end)
@@ -42,7 +42,7 @@ class BuilderTest < ActionView::TestCase
test 'collection radio accepts single disable item' do
collection = [[1, true], [0, false]]
- concat(form_for @user do |f|
+ concat(form_for(@user) do |f|
concat f.collection_radio :active, collection, :last, :first, :disabled => true
end)
@@ -51,7 +51,7 @@ class BuilderTest < ActionView::TestCase
end
test 'collection radio accepts html options as input' do
- concat(form_for @user do |f|
+ concat(form_for(@user) do |f|
concat f.collection_radio :active, [[1, true], [0, false]], :last, :first, {}, :class => 'radio'
end)
@@ -62,7 +62,7 @@ class BuilderTest < ActionView::TestCase
# COLLECTION CHECK BOX
test 'collection check box accepts a collection and generate a serie of checkboxes for value method' do
collection = [Tag.new(1, 'Tag 1'), Tag.new(2, 'Tag 2')]
- concat(form_for @user do |f|
+ concat(form_for(@user) do |f|
concat f.collection_check_boxes :tag_ids, collection, :id, :name
end)
@@ -73,7 +73,7 @@ class BuilderTest < ActionView::TestCase
test 'collection check box accepts a collection and generate a serie of checkboxes with labels for label method' do
collection = [Tag.new(1, 'Tag 1'), Tag.new(2, 'Tag 2')]
- concat(form_for @user do |f|
+ concat(form_for(@user) do |f|
concat f.collection_check_boxes :tag_ids, collection, :id, :name
end)
@@ -83,7 +83,7 @@ class BuilderTest < ActionView::TestCase
test 'collection check box accepts selected values as :checked option' do
collection = (1..3).map{|i| [i, "Tag #{i}"] }
- concat(form_for @user do |f|
+ concat(form_for(@user) do |f|
concat f.collection_check_boxes :tag_ids, collection, :first, :last, :checked => [1, 3]
end)
@@ -94,7 +94,7 @@ class BuilderTest < ActionView::TestCase
test 'collection check box accepts a single checked value' do
collection = (1..3).map{|i| [i, "Tag #{i}"] }
- concat(form_for @user do |f|
+ concat(form_for(@user) do |f|
concat f.collection_check_boxes :tag_ids, collection, :first, :last, :checked => 3
end)
@@ -105,7 +105,7 @@ class BuilderTest < ActionView::TestCase
test 'collection check box accepts multiple disabled items' do
collection = (1..3).map{|i| [i, "Tag #{i}"] }
- concat(form_for @user do |f|
+ concat(form_for(@user) do |f|
concat f.collection_check_boxes :tag_ids, collection, :first, :last, :disabled => [1, 3]
end)
@@ -116,7 +116,7 @@ class BuilderTest < ActionView::TestCase
test 'collection check box accepts single disable item' do
collection = (1..3).map{|i| [i, "Tag #{i}"] }
- concat(form_for @user do |f|
+ concat(form_for(@user) do |f|
concat f.collection_check_boxes :tag_ids, collection, :first, :last, :disabled => 1
end)
@@ -127,7 +127,7 @@ class BuilderTest < ActionView::TestCase
test 'collection check box accepts a proc to disabled items' do
collection = (1..3).map{|i| [i, "Tag #{i}"] }
- concat(form_for @user do |f|
+ concat(form_for(@user) do |f|
concat f.collection_check_boxes :tag_ids, collection, :first, :last, :disabled => proc { |i| i.first == 1 }
end)
@@ -138,7 +138,7 @@ class BuilderTest < ActionView::TestCase
test 'collection check box accepts html options' do
collection = [[1, 'Tag 1'], [2, 'Tag 2']]
- concat(form_for @user do |f|
+ concat(form_for(@user) do |f|
concat f.collection_check_boxes :tag_ids, collection, :first, :last, {}, :class => 'check'
end)
@@ -148,8 +148,8 @@ class BuilderTest < ActionView::TestCase
test 'collection check box with fields for' do
collection = [Tag.new(1, 'Tag 1'), Tag.new(2, 'Tag 2')]
- concat(form_for @user do |f|
- concat(f.fields_for :post do |p|
+ concat(form_for(@user) do |f|
+ concat(f.fields_for(:post) do |p|
concat p.collection_check_boxes :tag_ids, collection, :id, :name
end)
end)
@@ -163,8 +163,8 @@ class BuilderTest < ActionView::TestCase
# SIMPLE FIELDS
test 'simple fields for is available and yields an instance of FormBuilder' do
- concat(form_for @user do |f|
- concat(f.simple_fields_for :posts do |posts_form|
+ concat(form_for(@user) do |f|
+ concat(f.simple_fields_for(:posts) do |posts_form|
assert posts_form.instance_of?(SimpleForm::FormBuilder)
end)
end)
@@ -9,28 +9,28 @@ class FormHelperTest < ActionView::TestCase
end
test 'simple form should add default class to form' do
- concat(simple_form_for :user do |f| end)
+ concat(simple_form_for(:user) do |f| end)
assert_select 'form.simple_form'
end
test 'simple form should add object name as css class to form when object is not present' do
- concat(simple_form_for :user do |f| end)
+ concat(simple_form_for(:user) do |f| end)
assert_select 'form.simple_form.user'
end
test 'simple form should add object class name as css class to form' do
- concat(simple_form_for @user do |f| end)
+ concat(simple_form_for(@user) do |f| end)
assert_select 'form.simple_form.user'
end
test 'pass options to simple form' do
- concat(simple_form_for :user, :url => '/account', :html => { :id => 'my_form' } do |f| end)
+ concat(simple_form_for(:user, :url => '/account', :html => { :id => 'my_form' }) do |f| end)
assert_select 'form#my_form'
assert_select 'form[action=/account]'
end
test 'fields for yields an instance of FormBuilder' do
- concat(simple_fields_for :user do |f|
+ concat(simple_fields_for(:user) do |f|
assert f.instance_of?(SimpleForm::FormBuilder)
end)
end
@@ -3,7 +3,7 @@
class ErrorTest < ActionView::TestCase
def with_error_for(object, attribute_name, type, options={}, &block)
- concat(simple_form_for object do |f|
+ concat(simple_form_for(object) do |f|
f.attribute_name = attribute_name
f.reflection = Association.new(Company, :company, {}) if options.delete(:setup_association)
f.input_type = type
@@ -3,7 +3,7 @@
class HintTest < ActionView::TestCase
def with_hint_for(object, attribute_name, type, options={}, &block)
- concat(simple_form_for object do |f|
+ concat(simple_form_for(object) do |f|
f.attribute_name = attribute_name
f.reflection = Association.new(Company, :company, {}) if options.delete(:setup_association)
f.input_type = type
@@ -1,3 +1,4 @@
+# encoding: UTF-8
require 'test_helper'
class LabelTest < ActionView::TestCase
@@ -7,7 +8,7 @@ class LabelTest < ActionView::TestCase
end
def with_label_for(object, attribute_name, type, options={})
- concat(simple_form_for object do |f|
+ concat(simple_form_for(object) do |f|
f.attribute_name = attribute_name
f.reflection = Association.new(Company, :company, {}) if options.delete(:setup_association)
f.input_type = type
@@ -94,14 +95,14 @@ def with_label_for(object, attribute_name, type, options={})
with_label_for @user, :created_at, :datetime
assert_select 'label.datetime'
end
-
+
test 'label should obtain required from ActiveModel::Validations when it is included' do
with_label_for @validating_user, :name, :string
assert_select 'label.required'
with_label_for @validating_user, :status, :string
assert_select 'label.optional'
end
-
+
test 'label should allow overriding required when ActiveModel::Validations is included' do
with_label_for @validating_user, :name, :string, :required => false
assert_select 'label.optional'
@@ -2,14 +2,14 @@
class WrapperTest < ActionView::TestCase
def with_error_for(object, attribute_name, options={}, &block)
- concat(simple_form_for object do |f|
+ concat(simple_form_for(object) do |f|
f.options = options
f.input attribute_name
end)
end
def with_form_for(object, *args, &block)
- concat(simple_form_for object do |f|
+ concat(simple_form_for(object) do |f|
concat f.input(*args, &block)
end)
end
View
@@ -1,39 +1,40 @@
+# encoding: UTF-8
require 'test_helper'
class FormBuilderTest < ActionView::TestCase
def with_form_for(object, *args, &block)
- concat(simple_form_for object do |f|
+ concat(simple_form_for(object) do |f|
concat f.input(*args, &block)
end)
end
def with_button_for(object, *args)
- concat(simple_form_for object do |f|
+ concat(simple_form_for(object) do |f|
concat f.button(*args)
end)
end
def with_error_for(object, *args)
- concat(simple_form_for object do |f|
+ concat(simple_form_for(object) do |f|
concat f.error(*args)
end)
end
def with_hint_for(object, *args)
- concat(simple_form_for object do |f|
+ concat(simple_form_for(object) do |f|
concat f.hint(*args)
end)
end
def with_label_for(object, *args)
- concat(simple_form_for object do |f|
+ concat(simple_form_for(object) do |f|
concat f.label(*args)
end)
end
def with_association_for(object, *args)
- concat(simple_form_for object do |f|
+ concat(simple_form_for(object) do |f|
concat f.association(*args)
end)
end
@@ -229,26 +230,26 @@ def with_association_for(object, *args)
assert_select 'span.error#cool', "can't be blank"
end
- # REQUIRED AND PRESENCE VALIDATION
+ # REQUIRED AND PRESENCE VALIDATION
test 'builder input should obtain required from ActiveModel::Validations when it is included' do
with_form_for @validating_user, :name
assert_select 'input.required#validating_user_name'
with_form_for @validating_user, :status
assert_select 'input.optional#validating_user_status'
end
-
+
test 'builder input should allow overriding required when ActiveModel::Validations is included' do
with_form_for @validating_user, :name, :required => false
assert_select 'input.optional#validating_user_name'
with_form_for @validating_user, :status, :required => true
assert_select 'input.required#validating_user_status'
end
-
+
test 'builder input should be required by default when ActiveModel::Validations is not included' do
with_form_for @user, :name
assert_select 'input.required#user_name'
end
-
+
test 'builder input should allow disabling required when ActiveModel::Validations is not included' do
with_form_for @user, :name, :required => false
assert_no_select 'input.required'
@@ -282,14 +283,14 @@ def with_association_for(object, *args)
end
test 'builder allows wrapper tag to be given on demand' do
- concat(simple_form_for @user do |f|
+ concat(simple_form_for(@user) do |f|
concat f.input :name, :wrapper_tag => :b
end)
assert_select 'form b.required.string'
end
test 'builder allows wrapper class to be given on demand' do
- concat(simple_form_for @user do |f|
+ concat(simple_form_for(@user) do |f|
concat f.input :name, :wrapper_class => :wrapper
end)
assert_select 'form div.wrapper.required.string'
Oops, something went wrong.

0 comments on commit 736df6f

Please sign in to comment.