add attachment object to account reports api
closes PS-438 test plan - do a GET to an account report - the results should include the attachment object Change-Id: I260b7a445c606877882d567a10348e5838392523 Reviewed-on: https://gerrit.instructure.com/21686 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Cody Cutrer <cody@instructure.com> QA-Review: Tyler Belnap <tyler@instructure.com> Product-Review: Rob Orton <rob@instructure.com>
This commit is contained in:
parent
6c7598144d
commit
112d70cc6c
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (C) 2012 Instructure, Inc.
|
# Copyright (C) 2012 - 2013 Instructure, Inc.
|
||||||
#
|
#
|
||||||
# This file is part of Canvas.
|
# This file is part of Canvas.
|
||||||
#
|
#
|
||||||
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
module Api::V1::AccountReport
|
module Api::V1::AccountReport
|
||||||
include Api::V1::Json
|
include Api::V1::Json
|
||||||
|
include Api::V1::Attachment
|
||||||
|
|
||||||
def account_reports_json(reports, user, session)
|
def account_reports_json(reports, user, session)
|
||||||
reports.map do |f|
|
reports.map do |f|
|
||||||
|
@ -31,8 +32,10 @@ module Api::V1::AccountReport
|
||||||
)
|
)
|
||||||
json[:status] = report.workflow_state
|
json[:status] = report.workflow_state
|
||||||
json[:report] = report.report_type
|
json[:report] = report.report_type
|
||||||
json[:file_url] = (report.attachment.nil? ? nil : "https://#{HostUrl.context_host(report.account)}/accounts/#{report.account.id}/files/#{report.attachment.id}/download")
|
json[:file_url] = (report.attachment.nil? ? nil : "https://#{HostUrl.context_host(report.account.root_account)}/accounts/#{report.account_id}/files/#{report.attachment.id}/download")
|
||||||
|
if report.attachment
|
||||||
|
json[:attachment] = attachment_json(report.attachment, user, :host => HostUrl.context_host(report.account.root_account))
|
||||||
|
end
|
||||||
json
|
json
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (C) 2012 Instructure, Inc.
|
# Copyright (C) 2012 - 2013 Instructure, Inc.
|
||||||
#
|
#
|
||||||
# This file is part of Canvas.
|
# This file is part of Canvas.
|
||||||
#
|
#
|
||||||
|
@ -89,7 +89,9 @@ describe 'Account Reports API', :type => :integration do
|
||||||
json['id'].should == @report.id
|
json['id'].should == @report.id
|
||||||
json['status'].should == @report.workflow_state
|
json['status'].should == @report.workflow_state
|
||||||
json['progress'].should == @report.progress
|
json['progress'].should == @report.progress
|
||||||
json['file_url'].should == "https://#{HostUrl.context_host(@admin.account)}/accounts/#{@admin.account.id}/files/#{@report.attachment.id}/download"
|
json['file_url'].should == "https://#{HostUrl.context_host(@admin.account)}/accounts/#{@admin.account.id}/files/#{@report.attachment_id}/download"
|
||||||
|
#test that attachment object is here, no need to test attachment json
|
||||||
|
json['attachment']['id'].should == @report.attachment_id
|
||||||
@report.parameters.each do |key, value|
|
@report.parameters.each do |key, value|
|
||||||
json['parameters'][key].should == value
|
json['parameters'][key].should == value
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue