No error message shown when clearing reading history fails
Description
When destroying the readings in the clear action, the readings_controller attempts to handle any possible errors by rescuing them. However, this is broken in a few ways. Instead of destroy, destroy! should be used so that an error is thrown when deletion fails. The error message should be shown to users as a flash error by using @errors to set flash[:error]. Ideally the error message should also be internationalized.
Testing
Automated testing only. The error message can be tested with rspec by stubbingdestroy! to raiseActiveRecord::RecordNotDestroyed.
When destroying the readings in the clear action, the readings_controller attempts to handle any possible errors by rescuing them. However, this is broken in a few ways. Instead of
destroy
,destroy!
should be used so that an error is thrown when deletion fails. The error message should be shown to users as a flash error by using@errors
to setflash[:error]
. Ideally the error message should also be internationalized.Testing
Automated testing only. The error message can be tested with rspec by stubbing
destroy!
to raiseActiveRecord::RecordNotDestroyed
.