diff --git a/app/models/submission.rb b/app/models/submission.rb
index b7ffc7af8cd..64b4d561768 100644
--- a/app/models/submission.rb
+++ b/app/models/submission.rb
@@ -469,7 +469,7 @@ class Submission < ActiveRecord::Base
def retrieve_lti_tii_score
if (tool = ContextExternalTool.tool_for_assignment(self.assignment))
- turnitin_data.select {|_,v| v.key?(:outcome_response) }.each do |k, v|
+ turnitin_data.select {|_,v| v.try(:key?, :outcome_response) }.each do |k, v|
Turnitin::OutcomeResponseProcessor.new(tool, self.assignment, self.user, v[:outcome_response].as_json).resubmit(self, k)
end
end
diff --git a/lib/support_helpers/tii.rb b/lib/support_helpers/tii.rb
index 2f65490299b..80bd04315e5 100644
--- a/lib/support_helpers/tii.rb
+++ b/lib/support_helpers/tii.rb
@@ -17,7 +17,7 @@ module SupportHelpers
notify "Success", "#{fixer_name} fixed #{prettify_broken_count} in #{Time.now.to_i - @start_time} seconds!"
rescue => error
- notify "Error", "#{fixer_name} failed because #{error.try(:message)}"
+ notify "Error", "#{fixer_name} failed because #{error.try(:message)}
#{error.try(:backtrace).try(:join, "
")}"
raise error
end
diff --git a/spec/lib/support_helpers/tii_spec.rb b/spec/lib/support_helpers/tii_spec.rb
index dbc10d26302..6bd95934ccb 100644
--- a/spec/lib/support_helpers/tii_spec.rb
+++ b/spec/lib/support_helpers/tii_spec.rb
@@ -33,13 +33,7 @@ describe SupportHelpers::Tii do
it 'emails the caller upon error' do
fixer = SupportHelpers::Tii::Fixer.new('email')
- Message.expects(:new).with(
- to: 'email',
- from: 'tii_script@instructure.com',
- subject: 'TurnItIn Fixer Error',
- body: "#{fixer.fixer_name} failed because SupportHelpers::Tii::Fixer must implement #fix",
- delay_for: 0
- )
+ Message.expects(:new)
Mailer.expects(:create_message)
begin
fixer.monitor_and_fix
diff --git a/spec/models/submission_spec.rb b/spec/models/submission_spec.rb
index c2cae0c3213..ec40cd3d2fe 100644
--- a/spec/models/submission_spec.rb
+++ b/spec/models/submission_spec.rb
@@ -553,6 +553,19 @@ describe Submission do
Turnitin::OutcomeResponseProcessor.stubs(:new).returns(outcome_response_processor_mock)
submission.retrieve_lti_tii_score
end
+
+ it 'resubmits errored tii attachments even if turnitin_data has non-hash values' do
+ a = @course.assignments.create!(title: "test",
+ submission_types: 'external_tool',
+ external_tool_tag_attributes: {url: tool.url})
+ submission.assignment = a
+ submission.turnitin_data = lti_tii_data.merge(last_processed_attempt: 1)
+ submission.user = @user
+ outcome_response_processor_mock = mock('outcome_response_processor')
+ outcome_response_processor_mock.expects(:resubmit).with(submission, "attachment_42")
+ Turnitin::OutcomeResponseProcessor.stubs(:new).returns(outcome_response_processor_mock)
+ submission.retrieve_lti_tii_score
+ end
end
end