aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/nested_attributes_test.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-08-25 17:55:16 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-08-25 17:55:16 -0700
commitf0c867fb50642af38d3410c18b5e6f4167b8ff3b (patch)
treeb69dc637c5207a68a3d6348bc0d0fe214e90f55a /activerecord/test/cases/nested_attributes_test.rb
parentaf31cf067242757b2005197b10a2dfbe6bb89184 (diff)
parentff8f759405609ed18d9ea3ca67c50ec5efc50acc (diff)
downloadrails-f0c867fb50642af38d3410c18b5e6f4167b8ff3b.tar.gz
rails-f0c867fb50642af38d3410c18b5e6f4167b8ff3b.tar.bz2
rails-f0c867fb50642af38d3410c18b5e6f4167b8ff3b.zip
Merge pull request #7449 from Mik-die/nested-limits
Allow to pass Symbol or Proc into :limit option of #accepts_nested_attributes_for
Diffstat (limited to 'activerecord/test/cases/nested_attributes_test.rb')
-rw-r--r--activerecord/test/cases/nested_attributes_test.rb38
1 files changed, 31 insertions, 7 deletions
diff --git a/activerecord/test/cases/nested_attributes_test.rb b/activerecord/test/cases/nested_attributes_test.rb
index 3a234f0cc1..725cff8f01 100644
--- a/activerecord/test/cases/nested_attributes_test.rb
+++ b/activerecord/test/cases/nested_attributes_test.rb
@@ -846,13 +846,7 @@ class TestNestedAttributesOnAHasAndBelongsToManyAssociation < ActiveRecord::Test
include NestedAttributesOnACollectionAssociationTests
end
-class TestNestedAttributesLimit < ActiveRecord::TestCase
- def setup
- Pirate.accepts_nested_attributes_for :parrots, :limit => 2
-
- @pirate = Pirate.create!(:catchphrase => "Don' botharrr talkin' like one, savvy?")
- end
-
+module NestedAttributesLimitTests
def teardown
Pirate.accepts_nested_attributes_for :parrots, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? }
end
@@ -876,6 +870,36 @@ class TestNestedAttributesLimit < ActiveRecord::TestCase
end
end
+class TestNestedAttributesLimitNumeric < ActiveRecord::TestCase
+ def setup
+ Pirate.accepts_nested_attributes_for :parrots, :limit => 2
+
+ @pirate = Pirate.create!(:catchphrase => "Don' botharrr talkin' like one, savvy?")
+ end
+
+ include NestedAttributesLimitTests
+end
+
+class TestNestedAttributesLimitSymbol < ActiveRecord::TestCase
+ def setup
+ Pirate.accepts_nested_attributes_for :parrots, :limit => :parrots_limit
+
+ @pirate = Pirate.create!(:catchphrase => "Don' botharrr talkin' like one, savvy?", :parrots_limit => 2)
+ end
+
+ include NestedAttributesLimitTests
+end
+
+class TestNestedAttributesLimitProc < ActiveRecord::TestCase
+ def setup
+ Pirate.accepts_nested_attributes_for :parrots, :limit => proc { 2 }
+
+ @pirate = Pirate.create!(:catchphrase => "Don' botharrr talkin' like one, savvy?")
+ end
+
+ include NestedAttributesLimitTests
+end
+
class TestNestedAttributesWithNonStandardPrimaryKeys < ActiveRecord::TestCase
fixtures :owners, :pets