mirror of
https://github.com/heartcombo/simple_form.git
synced 2022-11-09 12:19:26 -05:00
Fix preload collection tests
:preload => false was being used twice making two tests have the same implementation. Also the test that was supposed to test :preload => false with a collection was testing against a non-collection association.
This commit is contained in:
parent
c5f913c378
commit
f3d7ba7c12
1 changed files with 10 additions and 7 deletions
|
@ -43,6 +43,7 @@ class AssociationTest < ActionView::TestCase
|
|||
test 'builder preloads collection association' do
|
||||
value = @user.tags = Object.new
|
||||
value.expects(:to_a).returns(value)
|
||||
|
||||
with_association_for @user, :tags
|
||||
assert_select 'form select.select#user_tag_ids'
|
||||
assert_select 'form select option[value=1]', 'Tag 1'
|
||||
|
@ -51,19 +52,21 @@ class AssociationTest < ActionView::TestCase
|
|||
end
|
||||
|
||||
test 'builder does not preload collection association if preload is false' do
|
||||
value = @user.company = Object.new
|
||||
value = @user.tags = Object.new
|
||||
value.expects(:to_a).never
|
||||
with_association_for @user, :company, :preload => false
|
||||
assert_select 'form select.select#user_company_id'
|
||||
assert_select 'form select option[value=1]', 'Company 1'
|
||||
assert_select 'form select option[value=2]', 'Company 2'
|
||||
assert_select 'form select option[value=3]', 'Company 3'
|
||||
|
||||
with_association_for @user, :tags, :preload => false
|
||||
assert_select 'form select.select#user_tag_ids'
|
||||
assert_select 'form select option[value=1]', 'Tag 1'
|
||||
assert_select 'form select option[value=2]', 'Tag 2'
|
||||
assert_select 'form select option[value=3]', 'Tag 3'
|
||||
end
|
||||
|
||||
test 'builder does not preload non-collection association' do
|
||||
value = @user.company = Object.new
|
||||
value.expects(:to_a).never
|
||||
with_association_for @user, :company, :preload => false
|
||||
|
||||
with_association_for @user, :company
|
||||
assert_select 'form select.select#user_company_id'
|
||||
assert_select 'form select option[value=1]', 'Company 1'
|
||||
assert_select 'form select option[value=2]', 'Company 2'
|
||||
|
|
Loading…
Reference in a new issue