Skip to content

Commit f30e329

Browse files
author
Josh Orr
committed
Add a variable expansions iso8601
Canvas.assignment.unlockAt.iso8601 Canvas.assignment.lockAt.iso8601 Canvas.assignment.dueAt.iso8601 fixes PLAT-1211 test-plan: install the test tool with Canvas.assignment.unlockAt.iso8601 Canvas.assignment.lockAt.iso8601 Canvas.assignment.dueAt.iso8601 setup as a custom variable launch the tool it should return back the above date varibles in iso8601 format. Change-Id: I6a816e8318cb70d50a0cf39f2138f4e395f39676 Reviewed-on: https://gerrit.instructure.com/61806 Tested-by: Jenkins Reviewed-by: Nathan Mills <nathanm@instructure.com> QA-Review: August Thornton <august@instructure.com> Product-Review: Josh Orr <jgorr@instructure.com>
1 parent 894b1c9 commit f30e329

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

lib/lti/variable_expander.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,19 +289,33 @@ def expand_variables!(var_hash)
289289
register_expansion 'Canvas.assignment.pointsPossible', [],
290290
-> { @assignment.points_possible },
291291
ASSIGNMENT_GUARD
292-
292+
#deprecated in favor of ISO8601
293293
register_expansion 'Canvas.assignment.unlockAt', [],
294294
-> { @assignment.unlock_at },
295295
ASSIGNMENT_GUARD
296296

297+
#deprecated in favor of ISO8601
297298
register_expansion 'Canvas.assignment.lockAt', [],
298299
-> { @assignment.lock_at },
299300
ASSIGNMENT_GUARD
300301

302+
#deprecated in favor of ISO8601
301303
register_expansion 'Canvas.assignment.dueAt', [],
302304
-> { @assignment.due_at },
303305
ASSIGNMENT_GUARD
304306

307+
register_expansion 'Canvas.assignment.unlockAt.iso8601', [],
308+
-> { @assignment.unlock_at.utc.iso8601 },
309+
ASSIGNMENT_GUARD
310+
311+
register_expansion 'Canvas.assignment.lockAt.iso8601', [],
312+
-> { @assignment.lock_at.utc.iso8601 },
313+
ASSIGNMENT_GUARD
314+
315+
register_expansion 'Canvas.assignment.dueAt.iso8601', [],
316+
-> { @assignment.due_at.utc.iso8601 },
317+
ASSIGNMENT_GUARD
318+
305319
register_expansion 'LtiLink.custom.url', [],
306320
-> { @controller.show_lti_tool_settings_url(@tool_setting_link_id) },
307321
-> { @tool_setting_link_id }

spec/lib/lti/variable_expander_spec.rb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#
1818

1919
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
20-
2120
module Lti
2221
describe VariableExpander do
2322
let(:root_account) { Account.new }
@@ -382,6 +381,27 @@ module Lti
382381
expect(exp_hash[:test]).to eq right_now.to_s
383382
end
384383

384+
it 'has substitution for $Canvas.assignment.unlockAt.iso8601' do
385+
assignment.stubs(:unlock_at).returns(right_now)
386+
exp_hash = {test: '$Canvas.assignment.unlockAt.iso8601'}
387+
subject.expand_variables!(exp_hash)
388+
expect(exp_hash[:test]).to eq right_now.utc.iso8601.to_s
389+
end
390+
391+
it 'has substitution for $Canvas.assignment.lockAt.iso8601' do
392+
assignment.stubs(:lock_at).returns(right_now)
393+
exp_hash = {test: '$Canvas.assignment.lockAt.iso8601'}
394+
subject.expand_variables!(exp_hash)
395+
expect(exp_hash[:test]).to eq right_now.utc.iso8601.to_s
396+
end
397+
398+
it 'has substitution for $Canvas.assignment.dueAt.iso8601' do
399+
assignment.stubs(:due_at).returns(right_now)
400+
exp_hash = {test: '$Canvas.assignment.dueAt.iso8601'}
401+
subject.expand_variables!(exp_hash)
402+
expect(exp_hash[:test]).to eq right_now.utc.iso8601.to_s
403+
end
404+
385405
end
386406

387407
context 'user is logged in' do

0 commit comments

Comments
 (0)