Adjust variable substitution for membership service
fixes PLAT-1450 Test plan: * Using the test tool https://lti-tool-provider-example.herokuapp.com/ set up some XML for a tool that has a 'collaboration' placement and custom variable with the following variable substitution $Canvas.api.membershipServiceUrl * Ensure that on a course collaboration launch the membership service url is of the following form /api/lti/courses/:course_id/membership_service * Ensure that on an account group collaboration or course group collaboration launch the membership service url is of the following form /api/lti/groups/:group_id/membership_service Change-Id: I38ce63ba0d95a12963e99251c2abf660573e9c7b Reviewed-on: https://gerrit.instructure.com/78276 Reviewed-by: Nathan Mills <nathanm@instructure.com> Tested-by: Jenkins QA-Review: August Thornton <august@instructure.com> Product-Review: Andrew Butterfield <abutterfield@instructure.com>
This commit is contained in:
parent
7f81d18477
commit
bee6437f5a
|
@ -106,8 +106,8 @@ module Lti
|
|||
-> { "#{@request.scheme}://#{HostUrl.context_host(@root_account, @request.host)}" }
|
||||
|
||||
register_expansion 'Canvas.api.membershipServiceUrl', [],
|
||||
-> { @controller.course_membership_service_url(@context) },
|
||||
COURSE_GUARD
|
||||
-> { @controller.polymorphic_url([@context, :membership_service]) },
|
||||
-> { @context.is_a?(Course) || @context.is_a?(Group) }
|
||||
|
||||
# returns the account id for the current context.
|
||||
# @example
|
||||
|
|
|
@ -22,6 +22,8 @@ module Lti
|
|||
let(:root_account) { Account.new }
|
||||
let(:account) { Account.new(root_account: root_account) }
|
||||
let(:course) { Course.new(account: account) }
|
||||
let(:group_category) { course.group_categories.new(name: 'Category') }
|
||||
let(:group) { course.groups.new(name: 'Group', group_category: group_category) }
|
||||
let(:user) { User.new }
|
||||
let(:assignment) { Assignment.new }
|
||||
let(:substitution_helper) { stub_everything }
|
||||
|
@ -206,13 +208,25 @@ module Lti
|
|||
expect(exp_hash[:test]).to eq Shard.current.id
|
||||
end
|
||||
|
||||
context 'context is a group' do
|
||||
subject { described_class.new(root_account, group, controller, current_user: user) }
|
||||
|
||||
it 'has substitution for $Canvas.api.membershipServiceUrl when context is a group' do
|
||||
exp_hash = { test: '$Canvas.api.membershipServiceUrl' }
|
||||
group.stubs(:id).returns('1')
|
||||
controller.stubs(:polymorphic_url).returns("/api/lti/groups/#{group.id}/membership_service")
|
||||
subject.expand_variables!(exp_hash)
|
||||
expect(exp_hash[:test]).to eq "/api/lti/groups/1/membership_service"
|
||||
end
|
||||
end
|
||||
|
||||
context 'context is a course' do
|
||||
subject { described_class.new(root_account, course, controller, current_user: user) }
|
||||
|
||||
it 'has substitution for $Canvas.api.membershipServiceUrl' do
|
||||
it 'has substitution for $Canvas.api.membershipServiceUrl when context is a course' do
|
||||
exp_hash = { test: '$Canvas.api.membershipServiceUrl' }
|
||||
course.stubs(:id).returns('1')
|
||||
controller.stubs(:course_membership_service_url).returns("/api/lti/courses/#{course.id}/membership_service")
|
||||
controller.stubs(:polymorphic_url).returns("/api/lti/courses/#{course.id}/membership_service")
|
||||
subject.expand_variables!(exp_hash)
|
||||
expect(exp_hash[:test]).to eq "/api/lti/courses/1/membership_service"
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue