Problem with assert_raise in Unit Test

I’m running a simple unit test to validate that ActiveRecord raises an
exception when I try and update a column with a duplicate foreign key.

Inside the unit test,

charge.time_logs << time_logs(:first)

will generate

ActiveRecord::StatementInvalid: Mysql::Error: #23000Duplicate entry
‘20’ for key 2: UPDATE time_logs SET task_id = 1, date_created =
NULL, time_charge_id = 20, hours = 2.0, log_entry = NULL WHERE id
= 2

However,

 assert_raise ActiveRecord::StatementInvalid do
   charge.time_logs << time_logs(:first)
 end

will generate

ActiveRecord::StatementInvalid exception expected but none was
thrown.

What am I doing wrong?