プロジェクト

全般

プロフィール

Vote #67435

完了

TimelogController#destroy assumes success

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Code cleanup/refactoring_30
対象バージョン:
開始日:
2010/06/16
期日:
進捗率:

100%

予定工数:
category_id:
30
version_id:
14
issue_org_id:
5700
author_id:
5
assigned_to_id:
5
comments:
7
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

TimelogController#destroy assumes that deleting the TimeEntry always succeeds. It should check if @@time_entry.destroy@ was successful and change the flash message based on that.


journals

The only way, this line could fail, is when you have lost the db connection. I'm not sure if we are able to handle that gracefully.

This is also reflected in the "implementation of destroy":http://github.com/rails/rails/blob/2-3-stable/activerecord/lib/active_record/base.rb#L2612 The only thing that could bubble up is a general ActiveRecord error.

I think this is a 'won't fix'.
--------------------------------------------------------------------------------
Gregor Schmidt wrote:
> I think this is a 'won't fix'.

I disagree, it's easy for plugins to add callbacks to Models like before_delete. It's a UI inconsistency if Redmine is told to delete a record, it doesn't (for whatever reason), and the flash says it was deleted.

(Or alternatively) If Redmine itself ever did something in before_delete then someone will have to remember to change the controller because of the hard coded 'success' message. (e.g. if Redmine adds a permission for "Allowed to delete time entries".)
--------------------------------------------------------------------------------
patch coming in 5min
--------------------------------------------------------------------------------
patch which introduces an error message. includes a test that simulates a failing @before_destroy@ callback.

please check and commit if you think it's okay.
--------------------------------------------------------------------------------
(patch also adds check for successful flash message to the positive test)
--------------------------------------------------------------------------------
as Eric points out, a failing callback will rather return false than raise an error, adapted the patch
--------------------------------------------------------------------------------
Applied in r3805, thank you for the contribution.
--------------------------------------------------------------------------------

Admin Redmine さんが3年以上前に更新

  • カテゴリCode cleanup/refactoring_30 にセット
  • 対象バージョン1.0.0 (RC)_14 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0