aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorKevin Casey <kacasey@berkeley.edu>2014-02-08 08:44:10 -0800
committerKevin Casey <kacasey@berkeley.edu>2014-02-08 08:44:10 -0800
commit5e3d466d52fa4e9a42c3a1f8773a7c31da875e48 (patch)
treec20bd22beae53899e630c6cbf27c0c5401dad929 /activerecord/test/cases
parented66361488752aa115f8d95175cde6dd24f3496d (diff)
downloadrails-5e3d466d52fa4e9a42c3a1f8773a7c31da875e48.tar.gz
rails-5e3d466d52fa4e9a42c3a1f8773a7c31da875e48.tar.bz2
rails-5e3d466d52fa4e9a42c3a1f8773a7c31da875e48.zip
context in validation goes through has many relationship
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 a86fb15719..321440cab7 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -22,6 +22,8 @@ require 'models/engine'
require 'models/categorization'
require 'models/minivan'
require 'models/speedometer'
+require 'models/pirate'
+require 'models/ship'
class HasManyAssociationsTestForReorderWithJoinDependency < ActiveRecord::TestCase
fixtures :authors, :posts, :comments
@@ -1830,4 +1832,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