Cleanup tests removing calls to concat
This commit is contained in:
parent
1048a592eb
commit
146d18e6f8
|
@ -4,7 +4,7 @@ class BuilderTest < ActionView::TestCase
|
||||||
# COLLECTION RADIO
|
# COLLECTION RADIO
|
||||||
test 'collection radio accepts a collection and generate inputs from value method' do
|
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
|
f.collection_radio :active, [true, false], :to_s, :to_s
|
||||||
end)
|
end)
|
||||||
|
|
||||||
assert_select 'form input[type=radio][value=true]#user_active_true'
|
assert_select 'form input[type=radio][value=true]#user_active_true'
|
||||||
|
@ -13,7 +13,7 @@ class BuilderTest < ActionView::TestCase
|
||||||
|
|
||||||
test 'collection radio accepts a collection and generate inputs from label method' do
|
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
|
f.collection_radio :active, [true, false], :to_s, :to_s
|
||||||
end)
|
end)
|
||||||
|
|
||||||
assert_select 'form label.collection_radio[for=user_active_true]', 'true'
|
assert_select 'form label.collection_radio[for=user_active_true]', 'true'
|
||||||
|
@ -22,7 +22,7 @@ class BuilderTest < ActionView::TestCase
|
||||||
|
|
||||||
test 'collection radio accepts checked item' do
|
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
|
f.collection_radio :active, [[1, true], [0, false]], :last, :first, :checked => true
|
||||||
end)
|
end)
|
||||||
|
|
||||||
assert_select 'form input[type=radio][value=true][checked=checked]'
|
assert_select 'form input[type=radio][value=true][checked=checked]'
|
||||||
|
@ -32,7 +32,7 @@ class BuilderTest < ActionView::TestCase
|
||||||
test 'collection radio accepts multiple disabled items' do
|
test 'collection radio accepts multiple disabled items' do
|
||||||
collection = [[1, true], [0, false], [2, 'other']]
|
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]
|
f.collection_radio :active, collection, :last, :first, :disabled => [true, false]
|
||||||
end)
|
end)
|
||||||
|
|
||||||
assert_select 'form input[type=radio][value=true][disabled=disabled]'
|
assert_select 'form input[type=radio][value=true][disabled=disabled]'
|
||||||
|
@ -43,7 +43,7 @@ class BuilderTest < ActionView::TestCase
|
||||||
test 'collection radio accepts single disable item' do
|
test 'collection radio accepts single disable item' do
|
||||||
collection = [[1, true], [0, false]]
|
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
|
f.collection_radio :active, collection, :last, :first, :disabled => true
|
||||||
end)
|
end)
|
||||||
|
|
||||||
assert_select 'form input[type=radio][value=true][disabled=disabled]'
|
assert_select 'form input[type=radio][value=true][disabled=disabled]'
|
||||||
|
@ -52,7 +52,7 @@ class BuilderTest < ActionView::TestCase
|
||||||
|
|
||||||
test 'collection radio accepts html options as input' do
|
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'
|
f.collection_radio :active, [[1, true], [0, false]], :last, :first, {}, :class => 'radio'
|
||||||
end)
|
end)
|
||||||
|
|
||||||
assert_select 'form input[type=radio][value=true].radio#user_active_true'
|
assert_select 'form input[type=radio][value=true].radio#user_active_true'
|
||||||
|
@ -63,7 +63,7 @@ class BuilderTest < ActionView::TestCase
|
||||||
test 'collection check box accepts a collection and generate a serie of checkboxes for value method' do
|
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')]
|
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
|
f.collection_check_boxes :tag_ids, collection, :id, :name
|
||||||
end)
|
end)
|
||||||
|
|
||||||
assert_select "form input[type=hidden][name='user[tag_ids][]'][value=]"
|
assert_select "form input[type=hidden][name='user[tag_ids][]'][value=]"
|
||||||
|
@ -74,7 +74,7 @@ class BuilderTest < ActionView::TestCase
|
||||||
test 'collection check box accepts a collection and generate a serie of checkboxes with labels for label method' do
|
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')]
|
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
|
f.collection_check_boxes :tag_ids, collection, :id, :name
|
||||||
end)
|
end)
|
||||||
|
|
||||||
assert_select 'form label.collection_check_boxes[for=user_tag_ids_1]', 'Tag 1'
|
assert_select 'form label.collection_check_boxes[for=user_tag_ids_1]', 'Tag 1'
|
||||||
|
@ -84,7 +84,7 @@ class BuilderTest < ActionView::TestCase
|
||||||
test 'collection check box accepts selected values as :checked option' do
|
test 'collection check box accepts selected values as :checked option' do
|
||||||
collection = (1..3).map{|i| [i, "Tag #{i}"] }
|
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]
|
f.collection_check_boxes :tag_ids, collection, :first, :last, :checked => [1, 3]
|
||||||
end)
|
end)
|
||||||
|
|
||||||
assert_select 'form input[type=checkbox][value=1][checked=checked]'
|
assert_select 'form input[type=checkbox][value=1][checked=checked]'
|
||||||
|
@ -95,7 +95,7 @@ class BuilderTest < ActionView::TestCase
|
||||||
test 'collection check box accepts a single checked value' do
|
test 'collection check box accepts a single checked value' do
|
||||||
collection = (1..3).map{|i| [i, "Tag #{i}"] }
|
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
|
f.collection_check_boxes :tag_ids, collection, :first, :last, :checked => 3
|
||||||
end)
|
end)
|
||||||
|
|
||||||
assert_select 'form input[type=checkbox][value=3][checked=checked]'
|
assert_select 'form input[type=checkbox][value=3][checked=checked]'
|
||||||
|
@ -106,7 +106,7 @@ class BuilderTest < ActionView::TestCase
|
||||||
test 'collection check box accepts multiple disabled items' do
|
test 'collection check box accepts multiple disabled items' do
|
||||||
collection = (1..3).map{|i| [i, "Tag #{i}"] }
|
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]
|
f.collection_check_boxes :tag_ids, collection, :first, :last, :disabled => [1, 3]
|
||||||
end)
|
end)
|
||||||
|
|
||||||
assert_select 'form input[type=checkbox][value=1][disabled=disabled]'
|
assert_select 'form input[type=checkbox][value=1][disabled=disabled]'
|
||||||
|
@ -117,7 +117,7 @@ class BuilderTest < ActionView::TestCase
|
||||||
test 'collection check box accepts single disable item' do
|
test 'collection check box accepts single disable item' do
|
||||||
collection = (1..3).map{|i| [i, "Tag #{i}"] }
|
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
|
f.collection_check_boxes :tag_ids, collection, :first, :last, :disabled => 1
|
||||||
end)
|
end)
|
||||||
|
|
||||||
assert_select 'form input[type=checkbox][value=1][disabled=disabled]'
|
assert_select 'form input[type=checkbox][value=1][disabled=disabled]'
|
||||||
|
@ -128,7 +128,7 @@ class BuilderTest < ActionView::TestCase
|
||||||
test 'collection check box accepts a proc to disabled items' do
|
test 'collection check box accepts a proc to disabled items' do
|
||||||
collection = (1..3).map{|i| [i, "Tag #{i}"] }
|
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 }
|
f.collection_check_boxes :tag_ids, collection, :first, :last, :disabled => proc { |i| i.first == 1 }
|
||||||
end)
|
end)
|
||||||
|
|
||||||
assert_select 'form input[type=checkbox][value=1][disabled=disabled]'
|
assert_select 'form input[type=checkbox][value=1][disabled=disabled]'
|
||||||
|
@ -139,7 +139,7 @@ class BuilderTest < ActionView::TestCase
|
||||||
test 'collection check box accepts html options' do
|
test 'collection check box accepts html options' do
|
||||||
collection = [[1, 'Tag 1'], [2, 'Tag 2']]
|
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'
|
f.collection_check_boxes :tag_ids, collection, :first, :last, {}, :class => 'check'
|
||||||
end)
|
end)
|
||||||
|
|
||||||
assert_select 'form input.check[type=checkbox][value=1]'
|
assert_select 'form input.check[type=checkbox][value=1]'
|
||||||
|
@ -149,9 +149,9 @@ class BuilderTest < ActionView::TestCase
|
||||||
test 'collection check box with fields for' do
|
test 'collection check box with fields for' do
|
||||||
collection = [Tag.new(1, 'Tag 1'), Tag.new(2, 'Tag 2')]
|
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.fields_for(:post) do |p|
|
f.fields_for(:post) do |p|
|
||||||
concat p.collection_check_boxes :tag_ids, collection, :id, :name
|
p.collection_check_boxes :tag_ids, collection, :id, :name
|
||||||
end)
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
assert_select 'form input#user_post_tag_ids_1[type=checkbox][value=1]'
|
assert_select 'form input#user_post_tag_ids_1[type=checkbox][value=1]'
|
||||||
|
@ -164,9 +164,9 @@ class BuilderTest < ActionView::TestCase
|
||||||
# SIMPLE FIELDS
|
# SIMPLE FIELDS
|
||||||
test 'simple fields for is available and yields an instance of FormBuilder' do
|
test 'simple fields for is available and yields an instance of FormBuilder' do
|
||||||
concat(form_for(@user) do |f|
|
concat(form_for(@user) do |f|
|
||||||
concat(f.simple_fields_for(:posts) do |posts_form|
|
f.simple_fields_for(:posts) do |posts_form|
|
||||||
assert posts_form.instance_of?(SimpleForm::FormBuilder)
|
assert posts_form.instance_of?(SimpleForm::FormBuilder)
|
||||||
end)
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -9,7 +9,7 @@ class ErrorTest < ActionView::TestCase
|
||||||
f.input_type = type
|
f.input_type = type
|
||||||
f.options = options
|
f.options = options
|
||||||
|
|
||||||
concat(SimpleForm::Inputs::Base.new(f).error.to_s)
|
SimpleForm::Inputs::Base.new(f).error.to_s
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ class HintTest < ActionView::TestCase
|
||||||
f.input_type = type
|
f.input_type = type
|
||||||
f.options = options
|
f.options = options
|
||||||
|
|
||||||
concat(SimpleForm::Inputs::Base.new(f).hint.to_s)
|
SimpleForm::Inputs::Base.new(f).hint.to_s
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@ class LabelTest < ActionView::TestCase
|
||||||
f.input_type = type
|
f.input_type = type
|
||||||
f.options = options
|
f.options = options
|
||||||
|
|
||||||
concat(SimpleForm::Inputs::Base.new(f).label)
|
SimpleForm::Inputs::Base.new(f).label
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class WrapperTest < ActionView::TestCase
|
class WrapperTest < ActionView::TestCase
|
||||||
def with_error_for(object, attribute_name, options={}, &block)
|
def with_error_for(object, attribute_name, &block)
|
||||||
concat(simple_form_for(object) do |f|
|
concat(simple_form_for(object) do |f|
|
||||||
f.options = options
|
|
||||||
f.input attribute_name
|
f.input attribute_name
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_form_for(object, *args, &block)
|
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)
|
f.input(*args, &block)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@ class ErrorNotificationTest < ActionView::TestCase
|
||||||
|
|
||||||
def with_error_notification_for(object, options={}, &block)
|
def with_error_notification_for(object, options={}, &block)
|
||||||
concat(simple_form_for(object) do |f|
|
concat(simple_form_for(object) do |f|
|
||||||
concat(f.error_notification(options))
|
f.error_notification(options)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,37 +5,37 @@ class FormBuilderTest < ActionView::TestCase
|
||||||
|
|
||||||
def with_form_for(object, *args, &block)
|
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)
|
f.input(*args, &block)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_button_for(object, *args)
|
def with_button_for(object, *args)
|
||||||
concat(simple_form_for(object) do |f|
|
concat(simple_form_for(object) do |f|
|
||||||
concat f.button(*args)
|
f.button(*args)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_error_for(object, *args)
|
def with_error_for(object, *args)
|
||||||
concat(simple_form_for(object) do |f|
|
concat(simple_form_for(object) do |f|
|
||||||
concat f.error(*args)
|
f.error(*args)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_hint_for(object, *args)
|
def with_hint_for(object, *args)
|
||||||
concat(simple_form_for(object) do |f|
|
concat(simple_form_for(object) do |f|
|
||||||
concat f.hint(*args)
|
f.hint(*args)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_label_for(object, *args)
|
def with_label_for(object, *args)
|
||||||
concat(simple_form_for(object) do |f|
|
concat(simple_form_for(object) do |f|
|
||||||
concat f.label(*args)
|
f.label(*args)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_association_for(object, *args)
|
def with_association_for(object, *args)
|
||||||
concat(simple_form_for(object) do |f|
|
concat(simple_form_for(object) do |f|
|
||||||
concat f.association(*args)
|
f.association(*args)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ class FormBuilderTest < ActionView::TestCase
|
||||||
|
|
||||||
test 'builder input should allow a block to configure input' do
|
test 'builder input should allow a block to configure input' do
|
||||||
with_form_for @user, :name do
|
with_form_for @user, :name do
|
||||||
concat text_field_tag :foo, :bar, :id => :cool
|
text_field_tag :foo, :bar, :id => :cool
|
||||||
end
|
end
|
||||||
assert_no_select 'input.string'
|
assert_no_select 'input.string'
|
||||||
assert_select 'input#cool'
|
assert_select 'input#cool'
|
||||||
|
@ -300,14 +300,14 @@ class FormBuilderTest < ActionView::TestCase
|
||||||
|
|
||||||
test 'builder allows wrapper tag to be given on demand' do
|
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
|
f.input :name, :wrapper_tag => :b
|
||||||
end)
|
end)
|
||||||
assert_select 'form b.required.string'
|
assert_select 'form b.required.string'
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'builder allows wrapper class to be given on demand' do
|
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
|
f.input :name, :wrapper_class => :wrapper
|
||||||
end)
|
end)
|
||||||
assert_select 'form div.wrapper.required.string'
|
assert_select 'form div.wrapper.required.string'
|
||||||
end
|
end
|
||||||
|
@ -362,9 +362,9 @@ class FormBuilderTest < ActionView::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'builder should generate a hint component tag for the given text' do
|
test 'builder should generate a hint component tag for the given text' do
|
||||||
with_hint_for @user, 'Hello World!'
|
with_hint_for @user, 'Hello World!'
|
||||||
assert_select 'span.hint', 'Hello World!'
|
assert_select 'span.hint', 'Hello World!'
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'builder should allow passing options to hint tag' do
|
test 'builder should allow passing options to hint tag' do
|
||||||
with_hint_for @user, :name, :hint => 'Hello World!', :id => 'name_hint'
|
with_hint_for @user, :name, :hint => 'Hello World!', :id => 'name_hint'
|
|
@ -9,7 +9,7 @@ class InputTest < ActionView::TestCase
|
||||||
|
|
||||||
def with_input_for(object, attribute_name, type, options={})
|
def with_input_for(object, attribute_name, type, options={})
|
||||||
concat(simple_form_for(object) do |f|
|
concat(simple_form_for(object) do |f|
|
||||||
concat f.input(attribute_name, options.merge(:as => type))
|
f.input(attribute_name, options.merge(:as => type))
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue