diff --git a/test/form_builder/association_test.rb b/test/form_builder/association_test.rb index 8df91e74..e62f970e 100644 --- a/test/form_builder/association_test.rb +++ b/test/form_builder/association_test.rb @@ -25,7 +25,7 @@ class AssociationTest < ActionView::TestCase test 'builder association forwards collection to simple_fields_for' do calls = 0 simple_form_for @user do |f| - f.association :company, collection: Company.all.to_a do |c| + f.association :company, collection: Company.all do |c| calls += 1 end end diff --git a/test/support/models.rb b/test/support/models.rb index 70c57ce9..fa8eb481 100644 --- a/test/support/models.rb +++ b/test/support/models.rb @@ -8,6 +8,8 @@ Column = Struct.new(:name, :type, :limit) do end Relation = Struct.new(:records) do + delegate :each, to: :records + def where(conditions = nil) self.class.new conditions ? records.first : records end @@ -16,7 +18,8 @@ Relation = Struct.new(:records) do self.class.new conditions ? records.last : records end - alias_method :to_a, :records + alias_method :to_a, :records + alias_method :to_ary, :records end Picture = Struct.new(:id, :name) do