Defect #5700 » 5700.diff
| app/controllers/timelog_controller.rb | ||
|---|---|---|
|
def destroy
|
||
|
(render_404; return) unless @time_entry
|
||
|
(render_403; return) unless @time_entry.editable_by?(User.current)
|
||
|
@time_entry.destroy
|
||
|
flash[:notice] = l(:notice_successful_delete)
|
||
|
begin
|
||
|
@time_entry.destroy
|
||
|
flash[:notice] = l(:notice_successful_delete)
|
||
|
rescue
|
||
|
flash[:error] = l(:notice_unable_delete_time_entry)
|
||
|
end
|
||
|
redirect_to :back
|
||
|
rescue ::ActionController::RedirectBackError
|
||
|
redirect_to :action => 'details', :project_id => @time_entry.project
|
||
| config/locales/de.yml | ||
|---|---|---|
|
notice_account_pending: "Ihr Konto wurde erstellt und wartet jetzt auf die Genehmigung des Administrators."
|
||
|
notice_default_data_loaded: Die Standard-Konfiguration wurde erfolgreich geladen.
|
||
|
notice_unable_delete_version: Die Version konnte nicht gelöscht werden.
|
||
|
notice_unable_delete_time_entry: Der Zeiterfassungseintrag konnte nicht gelöscht werden.
|
||
|
notice_issue_done_ratios_updated: Der Ticket-Fortschritt wurde aktualisiert.
|
||
|
error_can_t_load_default_data: "Die Standard-Konfiguration konnte nicht geladen werden: {{value}}"
|
||
| config/locales/en.yml | ||
|---|---|---|
|
notice_account_pending: "Your account was created and is now pending administrator approval."
|
||
|
notice_default_data_loaded: Default configuration successfully loaded.
|
||
|
notice_unable_delete_version: Unable to delete version.
|
||
|
notice_unable_delete_time_entry: Unable to delete time log entry.
|
||
|
notice_issue_done_ratios_updated: Issue done ratios updated.
|
||
|
|
||
|
error_can_t_load_default_data: "Default configuration could not be loaded: {{value}}"
|
||
| test/functional/timelog_controller_test.rb | ||
|---|---|---|
|
@request.session[:user_id] = 2
|
||
|
post :destroy, :id => 1
|
||
|
assert_redirected_to :action => 'details', :project_id => 'ecookbook'
|
||
|
assert_equal I18n.t(:notice_successful_delete), flash[:notice]
|
||
|
assert_nil TimeEntry.find_by_id(1)
|
||
|
end
|
||
|
|
||
|
def test_destroy_should_fail
|
||
|
# simulate that this fails (e.g. due to a plugin), see #5700
|
||
|
TimeEntry.class_eval do
|
||
|
before_destroy :produce_some_error
|
||
|
def produce_some_error ; raise ; end
|
||
|
end
|
||
|
@request.session[:user_id] = 2
|
||
|
post :destroy, :id => 1
|
||
|
assert_redirected_to :action => 'details', :project_id => 'ecookbook'
|
||
|
assert_equal I18n.t(:notice_unable_delete_time_entry), flash[:error]
|
||
|
assert_not_nil TimeEntry.find_by_id(1)
|
||
|
# remove the error simulation
|
||
|
TimeEntry.before_destroy.reject! {|callback| callback.method == :produce_some_error }
|
||
|
end
|
||
|
|
||
|
def test_report_no_criteria
|
||
|
get :report, :project_id => 1
|
||
|
assert_response :success
|
||