Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save spike008t/c002b782b3ebe02c5624 to your computer and use it in GitHub Desktop.
Save spike008t/c002b782b3ebe02c5624 to your computer and use it in GitHub Desktop.
Patch to be able to edit the time_entry object when updating an issue
From 8f1ebd2d9e1e0b88a59bcdb111191d1ef87b447a Mon Sep 17 00:00:00 2001
From: pkhim <[email protected]>
Date: Wed, 17 Sep 2014 15:55:35 +0200
Subject: [fix][issues] add the possibility to a plugin to modify the
time_entry object with the controller_issues_edit_before_save hook
---
app/controllers/issues_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index de346c5..bd9ef4a 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -471,10 +471,10 @@ class IssuesController < ApplicationController
time_entry.user = User.current
time_entry.spent_on = User.current.today
time_entry.attributes = params[:time_entry]
- @issue.time_entries << time_entry
end
call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => time_entry, :journal => @issue.current_journal})
+ @issue.time_entries << time_entry if time_entry
if @issue.save
call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => time_entry, :journal => @issue.current_journal})
else
--
1.9.3 (Apple Git-50)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment