# HG changeset patch
# Parent d3e15edbe7558c7cca83a397eb773ed047d85a1b

diff --git a/trunk/tracrpc/tests/ticket.py b/trunk/tracrpc/tests/ticket.py
--- a/trunk/tracrpc/tests/ticket.py
+++ b/trunk/tracrpc/tests/ticket.py
@@ -150,6 +150,21 @@
             for tid in tids:
                 self.admin.ticket.delete(tid)
 
+    def test_update_author(self):
+        tid = self.admin.ticket.create("ticket_update_author", "one", {})
+        self.admin.ticket.update(tid, 'comment1', {})
+        self.admin.ticket.update(tid, 'comment2', {}, False, 'foo')
+        changes = self.admin.ticket.changeLog(tid)
+        self.assertEquals(2, len(changes))
+        for when, who, what, cnum, comment, _tid in changes:
+            self.assertTrue(comment in ('comment1', 'comment2'))
+            if comment == 'comment1':
+                self.assertEquals('admin', who)
+            if comment == 'comment2':
+                self.assertEquals('foo', who)
+        self.admin.ticket.delete(tid)
+
+
 class RpcTicketVersionTestCase(TracRpcTestCase):
     
     def setUp(self):
diff --git a/trunk/tracrpc/ticket.py b/trunk/tracrpc/ticket.py
--- a/trunk/tracrpc/ticket.py
+++ b/trunk/tracrpc/ticket.py
@@ -44,7 +44,8 @@
         yield (None, ((list, int),), self.getActions)
         yield (None, ((list, int),), self.get)
         yield ('TICKET_CREATE', ((int, str, str), (int, str, str, dict), (int, str, str, dict, bool)), self.create)
-        yield (None, ((list, int, str), (list, int, str, dict), (list, int, str, dict, bool)), self.update)
+        yield (None, ((list, int, str), (list, int, str, dict), (list, int, str, dict, bool),
+                      (list, int, str, dict, bool, str)), self.update)
         yield (None, ((None, int),), self.delete)
         yield (None, ((dict, int), (dict, int, int)), self.changeLog)
         yield (None, ((list, int),), self.listAttachments)
@@ -141,7 +142,7 @@
         req.perm(t.resource).require('TICKET_VIEW')
         return (t.id, t.time_created, t.time_changed, t.values)
 
-    def create(self, req, summary, description, attributes = {}, notify=False):
+    def create(self, req, summary, description, attributes={}, notify=False):
         """ Create a new ticket, returning the ticket ID. """
         t = model.Ticket(self.env)
         t['summary'] = summary
@@ -165,11 +166,12 @@
                                    "of ticket #%s: %s" % (t.id, e))
         return t.id
 
-    def update(self, req, id, comment, attributes = {}, notify=False):
+    def update(self, req, id, comment, attributes={}, notify=False, author=''):
         """ Update a ticket, returning the new ticket in the same form as
         getTicket(). Requires a valid 'action' in attributes to support workflow. """
         now = to_datetime(None, utc)
         t = model.Ticket(self.env, id)
+        author = author or req.authname
         if not 'action' in attributes:
             # FIXME: Old, non-restricted update - remove soon!
             self.log.warning("Rpc ticket.update for ticket %d by user %s " \
@@ -177,7 +179,7 @@
             req.perm(t.resource).require('TICKET_MODIFY')
             for k, v in attributes.iteritems():
                 t[k] = v
-            t.save_changes(req.authname, comment, when=now)
+            t.save_changes(author, comment, when=now)
         else:
             ts = TicketSystem(self.env)
             tm = TicketModule(self.env)
@@ -205,13 +207,13 @@
             else:
                 tm._apply_ticket_changes(t, changes)
                 self.log.debug("Rpc ticket.update save: %s" % repr(t.values))
-                t.save_changes(req.authname, comment, when=now)
+                t.save_changes(author, comment, when=now)
                 # Apply workflow side-effects
                 for controller in controllers:
                     controller.apply_action_side_effects(req, t, action)
                 # Call ticket change listeners
                 for listener in ts.change_listeners:
-                    listener.ticket_changed(t, comment, req.authname, t._old)
+                    listener.ticket_changed(t, comment, author, t._old)
         if notify:
             try:
                 tn = TicketNotifyEmail(self.env)
