aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorEric Chahin <erc73@cornell.edu>2014-05-01 02:38:15 -0400
committerEric Chahin <erc73@cornell.edu>2014-05-01 03:27:24 -0400
commitc6d685ba1118cc1f6303122117df945ebe8fceae (patch)
treeb9d3b46fc5b454d8b8089411182da5cf936332c2 /activerecord/test/cases
parent876155705b56e66a8b9ed96f7b79d1c8d1763200 (diff)
downloadrails-c6d685ba1118cc1f6303122117df945ebe8fceae.tar.gz
rails-c6d685ba1118cc1f6303122117df945ebe8fceae.tar.bz2
rails-c6d685ba1118cc1f6303122117df945ebe8fceae.zip
Fixed custom validation context bug where child
associations were not being saved. Fixes #13854. [Eric Chahin, Aaron Nelson, & Kevin Casey]
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index 2f5c9d6e1b..000ea8055a 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -26,6 +26,8 @@ require 'models/reference'
require 'models/job'
require 'models/college'
require 'models/student'
+require 'models/pirate'
+require 'models/ship'
class HasManyAssociationsTestForReorderWithJoinDependency < ActiveRecord::TestCase
fixtures :authors, :posts, :comments
@@ -1877,4 +1879,12 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
end
end
end
+
+ test 'has_many_association passes context validation to validate children' do
+ pirate = FamousPirate.new
+ pirate.famous_ships << ship = FamousShip.new
+ assert_equal true, pirate.valid?
+ assert_equal false, pirate.valid?(:conference)
+ assert_equal "can't be blank", ship.errors[:name].first
+ end
end