aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorMichael Schuerig <michael@schuerig.de>2009-04-05 01:42:21 +0200
committerMichael Koziarski <michael@koziarski.com>2009-06-26 16:52:55 +1200
commit00a5fd3d18ac908af688c5944922cf69c56e850b (patch)
treeab0acf2af0a1404701fe04386e10e1f12084b630 /activerecord/test/cases
parent53a3eaa8603cf6e7a3c007f327fe5d3bb68de1ee (diff)
downloadrails-00a5fd3d18ac908af688c5944922cf69c56e850b.tar.gz
rails-00a5fd3d18ac908af688c5944922cf69c56e850b.tar.bz2
rails-00a5fd3d18ac908af688c5944922cf69c56e850b.zip
Translate foreign key violations to ActiveRecord::InvalidForeignKey exceptions.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
Diffstat (limited to 'activerecord/test/cases')
-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 8688fbee49..80530194ff 100644
--- a/activerecord/test/cases/adapter_test.rb
+++ b/activerecord/test/cases/adapter_test.rb
@@ -137,4 +137,12 @@ class AdapterTest < ActiveRecord::TestCase
@connection.execute "INSERT INTO subscribers(nick) VALUES('me')"
end
end
+
+ def test_foreign_key_violations_are_translated_to_specific_exception
+ unless @connection.adapter_name == 'SQLite'
+ assert_raises(ActiveRecord::InvalidForeignKey) do
+ @connection.execute "INSERT INTO fk_test_has_fk (fk_id) VALUES (0)"
+ end
+ end
+ end
end