Account Reports exported files go to inst-fs
closes RECNVS-372 test-plan - enable account reports in account plugins - navigate to account>settings>reports and select a report - after the report is generated, verify that the download comes from inst-fs not canvas Change-Id: I8d89fcf4889610bfd4a4ee10e7b09958553ab504 Reviewed-on: https://gerrit.instructure.com/145193 Reviewed-by: Jonathan Featherstone <jfeatherstone@instructure.com> Tested-by: Jenkins QA-Review: Collin Parrish <cparrish@instructure.com> Product-Review: Michael Jasper <mjasper@instructure.com>
This commit is contained in:
parent
a82c58d9b4
commit
fd852dc1f4
|
@ -121,13 +121,29 @@ module AccountReports
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if filename
|
if filename
|
||||||
|
data = Rack::Test::UploadedFile.new(filepath, filetype, true)
|
||||||
|
# have to branch here because calling the uploaded_data= method on attachment
|
||||||
|
# (done in the Attachments::Storage method) triggers an attachment_fu save
|
||||||
|
# callback which is handled differently than creating the attachment using
|
||||||
|
# the create! uploaded_data method, and assigns a different filename
|
||||||
|
# which report_attachment tests for :/
|
||||||
|
|
||||||
|
if InstFS.enabled?
|
||||||
|
attachment = account_report.account.attachments.new
|
||||||
|
Attachments::Storage.store_for_attachment(attachment, data)
|
||||||
|
attachment.display_name = filename
|
||||||
|
attachment.filename = filename
|
||||||
|
attachment.user = account_report.user
|
||||||
|
attachment.save!
|
||||||
|
else
|
||||||
attachment = account_report.account.attachments.create!(
|
attachment = account_report.account.attachments.create!(
|
||||||
:uploaded_data => Rack::Test::UploadedFile.new(filepath, filetype, true),
|
:uploaded_data => data,
|
||||||
:display_name => filename,
|
:display_name => filename,
|
||||||
:filename => filename,
|
:filename => filename,
|
||||||
:user => account_report.user
|
:user => account_report.user
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
attachment
|
attachment
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -41,4 +41,17 @@ describe "Account Reports" do
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "uses instfs if instfs is enabled" do
|
||||||
|
allow(InstFS).to receive(:enabled?).and_return(true)
|
||||||
|
uuid = "1234-abcd"
|
||||||
|
allow(InstFS).to receive(:direct_upload).and_return(uuid)
|
||||||
|
|
||||||
|
report1 = run_report('unpublished_courses_csv')
|
||||||
|
report2 = run_report('unpublished_courses_csv')
|
||||||
|
|
||||||
|
expect(report1.attachment.md5).to eq report2.attachment.md5
|
||||||
|
expect(report1.attachment.filename).not_to be == report2.attachment.filename
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue