Revert "handle nil content-disposition in tii"
This reverts commit 5fb3bac09e
.
Change-Id: I817271b8d7c78f0e1efedb656e480d906a003fc3
Reviewed-on: https://gerrit.instructure.com/135453
Tested-by: Jenkins
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
0bae449dbb
commit
f6a1559727
|
@ -41,8 +41,7 @@ module Turnitin
|
|||
def self.save_attachment(turnitin_client, user, attachment)
|
||||
Dir.mktmpdir do |dirname|
|
||||
turnitin_client.original_submission do |response|
|
||||
filename = 'default_filename.txt' if response.headers['content-disposition'].nil?
|
||||
filename ||= response.headers['content-disposition'].match(/filename=(\"?)(.+)\1/)[2]
|
||||
filename = response.headers['content-disposition'].match(/filename=(\"?)(.+)\1/)[2]
|
||||
filename.tr!('/','-')
|
||||
path = File.join(dirname, filename)
|
||||
File.open(path, 'wb') do |f|
|
||||
|
|
|
@ -43,24 +43,6 @@ module Turnitin
|
|||
|
||||
end
|
||||
|
||||
describe 'invalid response' do
|
||||
let(:response_mock) do
|
||||
r_mock = double('response')
|
||||
allow(r_mock).to receive(:headers).
|
||||
and_return({
|
||||
'content-disposition' => nil,
|
||||
'content-type' => 'plain/text'
|
||||
})
|
||||
allow(r_mock).to receive(:body).and_return('abcdef')
|
||||
r_mock
|
||||
end
|
||||
|
||||
it 'does not crash when there is no content-disposition' do
|
||||
subject.class.create_attachment(lti_student, lti_assignment, tool, outcome_response_json)
|
||||
expect(lti_assignment.attachments.first.display_name).to eq 'default_filename.txt'
|
||||
end
|
||||
end
|
||||
|
||||
describe '.update_attachment' do
|
||||
let(:submission) do
|
||||
sub = lti_assignment.submit_homework(
|
||||
|
|
Loading…
Reference in New Issue