Adding in assignment variable substitutions.
Fixes PLAT-907 Fixes PLAT-908 test plan - Make sure those variables are substituted correctly when in an assignment context. Change-Id: I56f3ba62dc53d9b8a39c5567588d68554092a842 Reviewed-on: https://gerrit.instructure.com/50275 Tested-by: Jenkins Reviewed-by: Brad Humphrey <brad@instructure.com> QA-Review: August Thornton <august@instructure.com> Product-Review: Brad Humphrey <brad@instructure.com>
This commit is contained in:
parent
6d8def10c6
commit
e01e46fbaf
|
@ -255,6 +255,18 @@ module Lti
|
|||
-> { @assignment.points_possible },
|
||||
ASSIGNMENT_GUARD
|
||||
|
||||
register_expansion 'Canvas.assignment.unlockAt', [],
|
||||
-> { @assignment.unlock_at },
|
||||
ASSIGNMENT_GUARD
|
||||
|
||||
register_expansion 'Canvas.assignment.lockAt', [],
|
||||
-> { @assignment.lock_at },
|
||||
ASSIGNMENT_GUARD
|
||||
|
||||
register_expansion 'Canvas.assignment.dueAt', [],
|
||||
-> { @assignment.due_at },
|
||||
ASSIGNMENT_GUARD
|
||||
|
||||
register_expansion 'LtiLink.custom.url', [],
|
||||
-> { @controller.show_lti_tool_settings_url(@tool_setting_link_id) },
|
||||
-> { @tool_setting_link_id }
|
||||
|
|
|
@ -24,7 +24,9 @@ module Lti
|
|||
let(:account) { Account.new(root_account: root_account) }
|
||||
let(:course) { Course.new(account: account) }
|
||||
let(:user) { User.new }
|
||||
let(:assignment) { Assignment.new }
|
||||
let(:substitution_helper) { stub_everything }
|
||||
let(:right_now) { DateTime.now }
|
||||
let(:tool) do
|
||||
m = mock('tool')
|
||||
m.stubs(:id).returns(1)
|
||||
|
@ -235,6 +237,55 @@ module Lti
|
|||
end
|
||||
end
|
||||
|
||||
context 'context is a course with an assignment' do
|
||||
subject { described_class.new(root_account, course, controller, current_user: user, assignment: assignment) }
|
||||
|
||||
it 'has substitution for $Canvas.assignment.id' do
|
||||
assignment.stubs(:id).returns(2015)
|
||||
exp_hash = {test: '$Canvas.assignment.id'}
|
||||
subject.expand_variables!(exp_hash)
|
||||
expect(exp_hash[:test]).to eq 2015
|
||||
end
|
||||
|
||||
it 'has substitution for $Canvas.assignment.title' do
|
||||
assignment.title = 'Buy as many ducks as you can'
|
||||
exp_hash = {test: '$Canvas.assignment.title'}
|
||||
subject.expand_variables!(exp_hash)
|
||||
expect(exp_hash[:test]).to eq 'Buy as many ducks as you can'
|
||||
end
|
||||
|
||||
it 'has substitution for $Canvas.assignment.pointsPossible' do
|
||||
assignment.stubs(:points_possible).returns(10)
|
||||
exp_hash = {test: '$Canvas.assignment.pointsPossible'}
|
||||
subject.expand_variables!(exp_hash)
|
||||
expect(exp_hash[:test]).to eq 10
|
||||
end
|
||||
|
||||
|
||||
|
||||
it 'has substitution for $Canvas.assignment.unlockAt' do
|
||||
assignment.stubs(:unlock_at).returns(right_now.to_s)
|
||||
exp_hash = {test: '$Canvas.assignment.unlockAt'}
|
||||
subject.expand_variables!(exp_hash)
|
||||
expect(exp_hash[:test]).to eq right_now.to_s
|
||||
end
|
||||
|
||||
it 'has substitution for $Canvas.assignment.lockAt' do
|
||||
assignment.stubs(:lock_at).returns(right_now.to_s)
|
||||
exp_hash = {test: '$Canvas.assignment.lockAt'}
|
||||
subject.expand_variables!(exp_hash)
|
||||
expect(exp_hash[:test]).to eq right_now.to_s
|
||||
end
|
||||
|
||||
it 'has substitution for $Canvas.assignment.dueAt' do
|
||||
assignment.stubs(:due_at).returns(right_now.to_s)
|
||||
exp_hash = {test: '$Canvas.assignment.dueAt'}
|
||||
subject.expand_variables!(exp_hash)
|
||||
expect(exp_hash[:test]).to eq right_now.to_s
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'user is logged in' do
|
||||
|
||||
it 'has substitution for $Person.name.full' do
|
||||
|
|
Loading…
Reference in New Issue