aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/belongs_to_associations_test.rb
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2016-12-29 20:09:43 +0100
committerGitHub <noreply@github.com>2016-12-29 20:09:43 +0100
commitca3eb2c1569a86e9c7eee2e9877dd773797a76b4 (patch)
tree016b5f2247d6ad4d95f1b1f05c897b5472abb7bf /activerecord/test/cases/associations/belongs_to_associations_test.rb
parent654704247eba742e139cfaa8d1385f13605d9e12 (diff)
parentc491bf012948383632e53f874c552041a6e23b36 (diff)
downloadrails-ca3eb2c1569a86e9c7eee2e9877dd773797a76b4.tar.gz
rails-ca3eb2c1569a86e9c7eee2e9877dd773797a76b4.tar.bz2
rails-ca3eb2c1569a86e9c7eee2e9877dd773797a76b4.zip
Merge branch 'master' into fix_26964
Diffstat (limited to 'activerecord/test/cases/associations/belongs_to_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/belongs_to_associations_test.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb
index 72f1b3b125..b75e2a47a6 100644
--- a/activerecord/test/cases/associations/belongs_to_associations_test.rb
+++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb
@@ -1057,7 +1057,7 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase
comment.parent = nil
comment.save!
- assert_equal nil, comment.reload.parent
+ assert_nil comment.reload.parent
assert_equal 0, comments(:greetings).reload.children_count
end
@@ -1072,6 +1072,20 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase
assert_equal 1, parent.reload.children_count
end
+ def test_belongs_to_with_out_of_range_value_assigning
+ model = Class.new(Comment) do
+ def self.name; "Temp"; end
+ validates :post, presence: true
+ end
+
+ comment = model.new
+ comment.post_id = 9223372036854775808 # out of range in the bigint
+
+ assert_nil comment.post
+ assert_not comment.valid?
+ assert_equal [{ error: :blank }], comment.errors.details[:post]
+ end
+
def test_polymorphic_with_custom_primary_key
toy = Toy.create!
sponsor = Sponsor.create!(sponsorable: toy)