Fix working with file attachment drafts.

Review Request #5244 — Created Jan. 13, 2014 and submitted — Latest diff uploaded

Information

Review Board
master

Reviewers

Fix working with file attachment drafts.

File attachment drafts were a bit broken. The API would return the
non-draft version, meaning it would contain the old caption and not the
new caption. We didn't notice this before the JavaScript rewrite,
because we just showed the local caption we saved, but this is more
apparent now.

The server-side resource now specifically serializes the resulting file
attachment using itself instead of the default serializer.

The JavaScript side now has a DraftFileAttachment object that's used for
all file attachments on the review request page. This is just a thin
wrapper around FileAttachment that makes use of the draft resource.

Set the caption of a file attachment and saw it reflected in the UI.
Verified the correct contents of the request and response payloads.

Reloaded the page and saw that the caption was persistent.

JavaScript unit tests pass. Note that I didn't add any new tests to
test caption saving because the bug was really about the interaction
with resources on the server. Best we can do is simulate what we think
we're going to get.