Use relative path in originality report launch redirect

Fixes PLAT-2910

Test Plan:
- Create a sub-account that has a different domain
  than its root account.
- Install a plagiarism detection tool in the sub-account
  and associate it win an assignment.
- As a student submit to the assignment
- Create an originality report that does an LTI
  launch for the submission
- As the student click on the originality score.
  Verify the URL you are eventually redirected to matches
  the domain of the sub-account, not the root account.

Change-Id: I2928e2c5a3ed167c4f0ee72291449d855aa53535
Reviewed-on: https://gerrit.instructure.com/131757
Reviewed-by: Andrew Butterfield <abutterfield@instructure.com>
Tested-by: Jenkins
Reviewed-by: Nathan Mills <nathanm@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Weston Dransfield <wdransfield@instructure.com>
This commit is contained in:
wdransfield 2017-11-03 08:30:18 -06:00 committed by Weston Dransfield
parent c9bb131498
commit 3f8f1cad83
3 changed files with 7 additions and 7 deletions

View File

@ -53,9 +53,9 @@ class OriginalityReport < ActiveRecord::Base
end
end
def report_launch_url
def report_launch_path
if lti_link.present?
course_assignment_resource_link_id_url(course_id: assignment.context_id,
course_assignment_resource_link_id_path(course_id: assignment.context_id,
assignment_id: assignment.id,
resource_link_id: lti_link.resource_link_id,
host: HostUrl.context_host(assignment.context),

View File

@ -660,7 +660,7 @@ class Submission < ActiveRecord::Base
if self.grants_right?(user, :view_turnitin_report)
requested_attachment = all_versioned_attachments.find_by_asset_string(asset_string)
report = self.originality_reports.find_by(attachment: requested_attachment)
url = report&.report_launch_url
url = report&.report_launch_path
end
url
end

View File

@ -179,7 +179,7 @@ describe OriginalityReport do
end
end
describe '#report_launch_url' do
describe '#report_launch_path' do
include_context 'lti2_spec_helper'
let(:lti_link) do
Lti::Link.new(resource_link_id: SecureRandom.uuid,
@ -192,16 +192,16 @@ describe OriginalityReport do
it 'creates an LTI launch URL if a lti_link is present' do
report.update_attributes(lti_link: lti_link)
expected_url = "http://localhost/courses/"\
expected_url = "/courses/"\
"#{submission.assignment.course.id}/assignments/"\
"#{submission.assignment.id}/lti/resource/#{lti_link.resource_link_id}?display=borderless"
expect(report.report_launch_url).to eq expected_url
expect(report.report_launch_path).to eq expected_url
end
it 'uses the originality_report_url when the link id is present' do
non_lti_url = 'http://www.test.com/report'
report.update_attributes(originality_report_url: non_lti_url)
expect(report.report_launch_url).to eq non_lti_url
expect(report.report_launch_path).to eq non_lti_url
end
end