add timestamps to account report api

fixes CORE-1076

test plan
 - specs should pass

Change-Id: Id0b88c21a606a69ec5663864f4303ba95101c14a
Reviewed-on: https://gerrit.instructure.com/142386
Reviewed-by: James Williams  <jamesw@instructure.com>
Tested-by: Jenkins
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
This commit is contained in:
Rob Orton 2018-03-01 15:50:47 -07:00
parent ce6788c51c
commit 9c06bf6d91
3 changed files with 23 additions and 9 deletions

View File

@ -48,6 +48,21 @@
# "example": "complete",
# "type": "string"
# },
# "created_at": {
# "description": "The date and time the report was created.",
# "example": "2013-12-01T23:59:00-06:00",
# "type": "datetime"
# },
# "started_at": {
# "description": "The date and time the report started processing.",
# "example": "2013-12-02T00:03:21-06:00",
# "type": "datetime"
# },
# "ended_at": {
# "description": "The date and time the report finished processing.",
# "example": "2013-12-02T00:03:21-06:00",
# "type": "datetime"
# },
# "parameters": {
# "description": "The report parameters",
# "example": {"course_id": 2, "start_at": "2012-07-13T10:55:20-06:00", "end_at": "2012-07-13T10:55:20-06:00"},

View File

@ -27,11 +27,12 @@ module Api::V1::AccountReport
end
def account_report_json(report, user, session)
json = api_json(report, user, session,
:only => %w(id progress parameters current_line)
)
json = api_json(report, user, session, only: %w(id progress parameters current_line))
json[:status] = report.workflow_state
json[:report] = report.report_type
json[:created_at] = report.created_at&.iso8601
json[:started_at] = report.start_at&.iso8601
json[:ended_at] = report.end_at&.iso8601
json[:file_url] = (report.attachment.nil? ? nil : account_file_download_url(report.account_id, report.attachment_id))
if report.attachment
json[:attachment] = attachment_json(report.attachment, user)

View File

@ -58,12 +58,10 @@ describe 'Account Reports API', type: :request do
describe 'create' do
it 'should create a student report' do
report = api_call(:post, "/api/v1/accounts/#{@admin.account.id}/reports/#{@report.report_type}",
{ :report=> @report.report_type, :controller => 'account_reports', :action => 'create', :format => 'json', :account_id => @admin.account.id.to_s })
expect(report.key?('id')).to be_truthy
expect(report.key?('status')).to be_truthy
expect(report.key?('progress')).to be_truthy
expect(report.key?('current_line')).to be_truthy
expect(report.key?('file_url')).to be_truthy
{report: @report.report_type, controller: 'account_reports', action: 'create',
format: 'json', account_id: @admin.account.id.to_s})
keys = %w(id progress parameters current_line status report created_at started_at ended_at file_url)
expect(keys - report.keys).to be_empty
end
it 'should work with parameters' do