aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapter_test.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2016-06-21 00:38:48 +0900
committerRyuta Kamizono <kamipo@gmail.com>2016-12-06 16:51:20 +0900
commitb270bc4ad021f051214420de1278627b1924b3b3 (patch)
tree2e977be2166a36858fd9fc657baebac8c934fbf8 /activerecord/test/cases/adapter_test.rb
parente10617303475488974fbe635d427f793faeb3f05 (diff)
downloadrails-b270bc4ad021f051214420de1278627b1924b3b3.tar.gz
rails-b270bc4ad021f051214420de1278627b1924b3b3.tar.bz2
rails-b270bc4ad021f051214420de1278627b1924b3b3.zip
Translate NOT NULL violation to the specific exception
Raise `ActiveRecord::NotNullViolation` when a record cannot be inserted or updated because it would violate a not null constraint.
Diffstat (limited to 'activerecord/test/cases/adapter_test.rb')
-rw-r--r--activerecord/test/cases/adapter_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapter_test.rb b/activerecord/test/cases/adapter_test.rb
index 8bcecf2ed3..2f0e8d866d 100644
--- a/activerecord/test/cases/adapter_test.rb
+++ b/activerecord/test/cases/adapter_test.rb
@@ -182,6 +182,14 @@ module ActiveRecord
assert_not_nil error.cause
end
+ def test_not_null_violations_are_translated_to_specific_exception
+ error = assert_raises(ActiveRecord::NotNullViolation) do
+ Post.create
+ end
+
+ assert_not_nil error.cause
+ end
+
unless current_adapter?(:SQLite3Adapter)
def test_foreign_key_violations_are_translated_to_specific_exception
error = assert_raises(ActiveRecord::InvalidForeignKey) do