fix expected speedgrader url template format

rails 2.3 to 3.2 changed the way that anchor tags are escaped in their url
builder methods from using CGI.escape (in 2.3) to URI.escape with a custom safe
list (in 3.2).  The changed caused the colon to stop being escaped.

fixes CNVS-14890

test plan:
- create an assignment discussion, and post to it as a several students
- as a teacher, use the "Open in Speedgrader" link in the discussion post cog
  menu for each student.
- it should open speedgrader to that specific student

Change-Id: I3d5aaae33b9b0e4914e09fa53292d9e042a91f26
Reviewed-on: https://gerrit.instructure.com/39752
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cameron Sutter <csutter@instructure.com>
QA-Review: Anna Koalenz <akoalenz@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
This commit is contained in:
Simon Williams 2014-08-21 16:51:47 -06:00
parent 7031a47387
commit b6b1ca7943
2 changed files with 13 additions and 1 deletions

View File

@ -154,7 +154,7 @@ define [
# ENV.DISCUSSION.SPEEDGRADER_URL_TEMPLATE will only exist if I have permission to grade
# and this thing is an assignment
if ENV.DISCUSSION.SPEEDGRADER_URL_TEMPLATE
ENV.DISCUSSION.SPEEDGRADER_URL_TEMPLATE.replace /%22%3Astudent_id%22/, @get('user_id')
ENV.DISCUSSION.SPEEDGRADER_URL_TEMPLATE.replace /%22:student_id%22/, @get('user_id')
##
# Computed attribute

View File

@ -141,6 +141,18 @@ describe DiscussionTopicsController do
assigns[:js_env][:DISCUSSION][:SPEEDGRADER_URL_TEMPLATE].should be_nil
end
it "should setup speedgrader template for variable substitution" do
user_session(@teacher)
course_topic(:with_assignment => true)
get 'show', :course_id => @course.id, :id => @topic.id
# this is essentially a unit test for app/coffeescripts/models/Entry.coffee,
# making sure that we get back the expected format for this url template
template = assigns[:js_env][:DISCUSSION][:SPEEDGRADER_URL_TEMPLATE]
url = template.gsub(/%22:student_id%22/, '123')
url.should match "%7B%22student_id%22:123%7D"
end
it "should mark as read when viewed" do
user_session(@student)
course_topic(:skip_set_user => true)