File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -146,7 +146,7 @@ def test_uniqueness_violations_are_translated_to_specific_exception
146146 end
147147
148148 def test_foreign_key_violations_are_translated_to_specific_exception
149- unless @connection . adapter_name == 'SQLite'
149+ unless current_adapter? ( :SQLite3Adapter )
150150 assert_raises ( ActiveRecord ::InvalidForeignKey ) do
151151 # Oracle adapter uses prefetched primary key values from sequence and passes them to connection adapter insert method
152152 if @connection . prefetch_primary_key?
@@ -159,6 +159,20 @@ def test_foreign_key_violations_are_translated_to_specific_exception
159159 end
160160 end
161161
162+ def test_foreign_key_violations_are_translated_to_specific_exception_with_validate_false
163+ unless current_adapter? ( :SQLite3Adapter )
164+ klass_has_fk = Class . new ( ActiveRecord ::Base ) do
165+ self . table_name = 'fk_test_has_fk'
166+ end
167+
168+ assert_raises ( ActiveRecord ::InvalidForeignKey ) do
169+ has_fk = klass_has_fk . new
170+ has_fk . fk_id = 1231231231
171+ has_fk . save ( validate : false )
172+ end
173+ end
174+ end
175+
162176 def test_disable_referential_integrity
163177 assert_nothing_raised do
164178 @connection . disable_referential_integrity do
You can’t perform that action at this time.
0 commit comments