@@ -225,8 +225,11 class TimelogController < ApplicationController | |||||
225 | def destroy |
|
225 | def destroy | |
226 | (render_404; return) unless @time_entry |
|
226 | (render_404; return) unless @time_entry | |
227 | (render_403; return) unless @time_entry.editable_by?(User.current) |
|
227 | (render_403; return) unless @time_entry.editable_by?(User.current) | |
228 | @time_entry.destroy |
|
228 | if @time_entry.destroy && @time_entry.destroyed? | |
229 | flash[:notice] = l(:notice_successful_delete) |
|
229 | flash[:notice] = l(:notice_successful_delete) | |
|
230 | else | |||
|
231 | flash[:error] = l(:notice_unable_delete_time_entry) | |||
|
232 | end | |||
230 | redirect_to :back |
|
233 | redirect_to :back | |
231 | rescue ::ActionController::RedirectBackError |
|
234 | rescue ::ActionController::RedirectBackError | |
232 | redirect_to :action => 'details', :project_id => @time_entry.project |
|
235 | redirect_to :action => 'details', :project_id => @time_entry.project |
@@ -175,6 +175,7 de: | |||||
175 | notice_account_pending: "Ihr Konto wurde erstellt und wartet jetzt auf die Genehmigung des Administrators." |
|
175 | notice_account_pending: "Ihr Konto wurde erstellt und wartet jetzt auf die Genehmigung des Administrators." | |
176 | notice_default_data_loaded: Die Standard-Konfiguration wurde erfolgreich geladen. |
|
176 | notice_default_data_loaded: Die Standard-Konfiguration wurde erfolgreich geladen. | |
177 | notice_unable_delete_version: Die Version konnte nicht gelöscht werden. |
|
177 | notice_unable_delete_version: Die Version konnte nicht gelöscht werden. | |
|
178 | notice_unable_delete_time_entry: Der Zeiterfassungseintrag konnte nicht gelöscht werden. | |||
178 | notice_issue_done_ratios_updated: Der Ticket-Fortschritt wurde aktualisiert. |
|
179 | notice_issue_done_ratios_updated: Der Ticket-Fortschritt wurde aktualisiert. | |
179 |
|
180 | |||
180 | error_can_t_load_default_data: "Die Standard-Konfiguration konnte nicht geladen werden: {{value}}" |
|
181 | error_can_t_load_default_data: "Die Standard-Konfiguration konnte nicht geladen werden: {{value}}" |
@@ -153,6 +153,7 en: | |||||
153 | notice_account_pending: "Your account was created and is now pending administrator approval." |
|
153 | notice_account_pending: "Your account was created and is now pending administrator approval." | |
154 | notice_default_data_loaded: Default configuration successfully loaded. |
|
154 | notice_default_data_loaded: Default configuration successfully loaded. | |
155 | notice_unable_delete_version: Unable to delete version. |
|
155 | notice_unable_delete_version: Unable to delete version. | |
|
156 | notice_unable_delete_time_entry: Unable to delete time log entry. | |||
156 | notice_issue_done_ratios_updated: Issue done ratios updated. |
|
157 | notice_issue_done_ratios_updated: Issue done ratios updated. | |
157 |
|
158 | |||
158 | error_can_t_load_default_data: "Default configuration could not be loaded: {{value}}" |
|
159 | error_can_t_load_default_data: "Default configuration could not be loaded: {{value}}" |
@@ -116,9 +116,27 class TimelogControllerTest < ActionController::TestCase | |||||
116 | @request.session[:user_id] = 2 |
|
116 | @request.session[:user_id] = 2 | |
117 | post :destroy, :id => 1 |
|
117 | post :destroy, :id => 1 | |
118 | assert_redirected_to :action => 'details', :project_id => 'ecookbook' |
|
118 | assert_redirected_to :action => 'details', :project_id => 'ecookbook' | |
|
119 | assert_equal I18n.t(:notice_successful_delete), flash[:notice] | |||
119 | assert_nil TimeEntry.find_by_id(1) |
|
120 | assert_nil TimeEntry.find_by_id(1) | |
120 | end |
|
121 | end | |
121 |
|
122 | |||
|
123 | def test_destroy_should_fail | |||
|
124 | # simulate that this fails (e.g. due to a plugin), see #5700 | |||
|
125 | TimeEntry.class_eval do | |||
|
126 | before_destroy :stop_callback_chain | |||
|
127 | def stop_callback_chain ; return false ; end | |||
|
128 | end | |||
|
129 | ||||
|
130 | @request.session[:user_id] = 2 | |||
|
131 | post :destroy, :id => 1 | |||
|
132 | assert_redirected_to :action => 'details', :project_id => 'ecookbook' | |||
|
133 | assert_equal I18n.t(:notice_unable_delete_time_entry), flash[:error] | |||
|
134 | assert_not_nil TimeEntry.find_by_id(1) | |||
|
135 | ||||
|
136 | # remove the simulation | |||
|
137 | TimeEntry.before_destroy.reject! {|callback| callback.method == :stop_callback_chain } | |||
|
138 | end | |||
|
139 | ||||
122 | def test_report_no_criteria |
|
140 | def test_report_no_criteria | |
123 | get :report, :project_id => 1 |
|
141 | get :report, :project_id => 1 | |
124 | assert_response :success |
|
142 | assert_response :success |
General Comments 0
You need to be logged in to leave comments.
Login now