reference instfs_uuid from instfs direct upload

refs RECNVS-521

* previously instfs file upload returned only the
instfs uuid as `uuid`
* instfs file upload now returns canvas capture
data, which includes the canvas uuid
* instfs uuid has been renamed to `instfs_uuid`

test plan:
* specs

Change-Id: I1f77f3dd1952fbd275ae67c399ff04ef6533785b
Reviewed-on: https://gerrit.instructure.com/157118
Reviewed-by: Michael Jasper <mjasper@instructure.com>
Tested-by: Jenkins
Product-Review: Xander Moffatt <xmoffatt@instructure.com>
QA-Review: Xander Moffatt <xmoffatt@instructure.com>
This commit is contained in:
Xander Moffatt 2018-07-12 09:56:02 -06:00
parent f2b9488d29
commit 7a4b731cdb
2 changed files with 5 additions and 5 deletions

View File

@ -127,9 +127,9 @@ module InstFS
response = CanvasHttp.post(url, form_data: data, multipart:true)
if response.class == Net::HTTPCreated
json_response = JSON.parse(response.body)
return json_response["uuid"] if json_response.key?("uuid")
return json_response["instfs_uuid"] if json_response.key?("instfs_uuid")
raise InstFS::DirectUploadError, "upload succeeded, but response did not containe a \"uuid\" key"
raise InstFS::DirectUploadError, "upload succeeded, but response did not containe an \"instfs_uuid\" key"
end
raise InstFS::DirectUploadError, "received code \"#{response.code}\" from service"
end

View File

@ -393,18 +393,18 @@ describe InstFS do
context "direct upload" do
it "makes a network request to the inst-fs endpoint" do
uuid = "1234-abcd"
instfs_uuid = "1234-abcd"
allow(CanvasHttp).to receive(:post).and_return(double(
class: Net::HTTPCreated,
code: 200,
body: {uuid: uuid}.to_json
body: {instfs_uuid: instfs_uuid}.to_json
))
res = InstFS.direct_upload(
file_name: "a.png",
file_object: File.open("public/images/a.png")
)
expect(res).to eq(uuid)
expect(res).to eq(instfs_uuid)
end
end
end