Adds a custom param with css info for lti launch

fixes CNVS-21837

Test plan:
* Set up sis_app
  * If you don't have it already, clone sis_app from gerrit
  * Then pull down g/58166
  * Run bundle, rake db:migrate, grunt webpack:build
  * Start the server with rails s -p 9292
  * Create a Skyward Agent if you haven't already (there are a lot of
    steps with this so just ping me if you have trouble)
* Canvas
  * Delete any existing Skyward GPB LTI tool you have installed
  * Reinstall the Skyward GPB tool
* Verifications
  * Go to post grades
  * Open up the javascript console in the browser
  * Monitor network traffic
  * Click the Skyward LTI tool in the Post Grades
    drop down menu
  * In the network traffic look for /post_grades
  * Click on that request and look through the form data sent with the
    post request
  * Ensure that there is a url to the common.css stylesheet under the
    key: custom_common_css_url
  * Verify that the url listed under that key matches the url for the
    common.css stylesheet in the Canvas grades page

Change-Id: I48e0aa74d498770513bcfa08f95537b922096b05
Reviewed-on: https://gerrit.instructure.com/58167
Tested-by: Jenkins
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Reviewed-by: Mark Severson <markse@instructure.com>
Reviewed-by: Brad Humphrey <brad@instructure.com>
Product-Review: Brad Humphrey <brad@instructure.com>
QA-Review: Ben Bolton <bbolton@instructure.com>
Product-Review: Matthew Wheeler <mwheeler@instructure.com>
This commit is contained in:
Andrew Butterfield 2015-07-10 10:28:43 -06:00 committed by Ben Bolton
parent bcd03e2445
commit e6368a1828
2 changed files with 15 additions and 0 deletions

View File

@ -114,6 +114,9 @@ module Lti
@tool.id, include_host:true) },
LTI1_GUARD
register_expansion 'Canvas.css.common', [],
-> { URI.parse(@request.url)
.merge(@controller.view_context.stylesheet_path(@controller.css_url_for(:common))).to_s }
##### Deprecated Substitutions #####

View File

@ -39,12 +39,18 @@ module Lti
end
let(:controller) do
request_mock = mock('request')
request_mock.stubs(:url).returns('https://localhost')
request_mock.stubs(:host).returns('/my/url')
request_mock.stubs(:scheme).returns('https')
m = mock('controller')
m.stubs(:css_url_for).with(:common).returns('/path/to/common.scss')
m.stubs(:request).returns(request_mock)
m.stubs(:logged_in_user).returns(user)
m.stubs(:named_context_url).returns('url')
view_context_mock = mock('view_context')
view_context_mock.stubs(:stylesheet_path)
.returns(URI.parse(request_mock.url).merge(m.css_url_for(:common)).to_s)
m.stubs(:view_context).returns(view_context_mock)
m
end
@ -125,6 +131,12 @@ module Lti
expect(exp_hash[:test]).to eq 'localhost'
end
it 'has substitution for $Canvas.css.common' do
exp_hash = {test: '$Canvas.css.common'}
subject.expand_variables!(exp_hash)
expect(exp_hash[:test]).to eq 'https://localhost/path/to/common.scss'
end
it 'has substitution for $Canvas.api.baseUrl' do
exp_hash = {test: '$Canvas.api.baseUrl'}
HostUrl.stubs(:context_host).returns('localhost')