aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations_test.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-03-01 12:31:43 -0800
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-03-01 12:31:43 -0800
commit35050ab26dcb99bafc7416c6d8fefd32131352b8 (patch)
tree05d9f7caf4d422a08aba1a5ab442926805a14b20 /activerecord/test/cases/associations_test.rb
parent99775fd1612217aaba2f3580b4204c6b75c04249 (diff)
parentb9399c470bc7cf85952ab0cc7113f4f825a1a7b3 (diff)
downloadrails-35050ab26dcb99bafc7416c6d8fefd32131352b8.tar.gz
rails-35050ab26dcb99bafc7416c6d8fefd32131352b8.tar.bz2
rails-35050ab26dcb99bafc7416c6d8fefd32131352b8.zip
Merge pull request #9510 from senny/7364_warn_when_appending_prepending_to_an_association
deal with `#append` and `#prepend` on association collections
Diffstat (limited to 'activerecord/test/cases/associations_test.rb')
-rw-r--r--activerecord/test/cases/associations_test.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/activerecord/test/cases/associations_test.rb b/activerecord/test/cases/associations_test.rb
index d7f25f760e..201fa5d5a9 100644
--- a/activerecord/test/cases/associations_test.rb
+++ b/activerecord/test/cases/associations_test.rb
@@ -172,6 +172,18 @@ class AssociationProxyTest < ActiveRecord::TestCase
assert_equal 1, josh.posts.size
end
+ def test_append_behaves_like_push
+ josh = Author.new(:name => "Josh")
+ josh.posts.append Post.new(:title => "New on Edge", :body => "More cool stuff!")
+ assert josh.posts.loaded?
+ assert_equal 1, josh.posts.size
+ end
+
+ def test_prepend_is_not_defined
+ josh = Author.new(:name => "Josh")
+ assert_raises(NoMethodError) { josh.posts.prepend Post.new }
+ end
+
def test_save_on_parent_does_not_load_target
david = developers(:david)
@@ -291,7 +303,7 @@ class OverridingAssociationsTest < ActiveRecord::TestCase
end
def test_requires_symbol_argument
- assert_raises ArgumentError do
+ assert_raises ArgumentError do
Class.new(Post) do
belongs_to "author"
end