add slash to chars to sanitize in gradebook export filename
Courses with slashes in the short name was breaking filenames for some users. This patchset adds / to the list of characters we substitute with an underscore. fixes GRADE-1037 test plan: - Have canvas configured to use s3 as a storage backend - Create a course with / (a slash) in the name. - Export the gradebook for that course - Observe that the gradebook export ran and the filename has substituted an underscore for the slash in the name Change-Id: Idfae52acae0d975c7fda92da7a57028ca21539b1 Reviewed-on: https://gerrit.instructure.com/147222 Tested-by: Jenkins Reviewed-by: Derek Bender <djbender@instructure.com> Reviewed-by: Adrian Packel <apackel@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
This commit is contained in:
parent
db262fa81f
commit
4f70606b32
|
@ -24,7 +24,7 @@ class GradebookCsvsController < ApplicationController
|
|||
if authorized_action(@context, @current_user, [:manage_grades, :view_all_grades])
|
||||
current_time = Time.zone.now.strftime('%FT%H%M')
|
||||
name = t('grades_filename', "Grades") + "-" + @context.short_name.to_s
|
||||
filename = "#{current_time}_#{name}.csv".gsub(/ /, '_')
|
||||
filename = "#{current_time}_#{name}.csv".gsub(%r{/| }, '_')
|
||||
|
||||
csv_options = {
|
||||
include_sis_id: @context.grants_any_right?(@current_user, session, :read_sis, :manage_sis),
|
||||
|
|
|
@ -22,7 +22,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|||
describe GradebookCsvsController do
|
||||
before :once do
|
||||
course_with_teacher active_all: true
|
||||
@course.short_name = "ENG101"
|
||||
@course.short_name = "ENG/ 101"
|
||||
@course.save
|
||||
end
|
||||
|
||||
|
@ -56,7 +56,7 @@ describe GradebookCsvsController do
|
|||
get 'show', params: {course_id: @course.id}, format: :json
|
||||
json = json_parse(response.body)
|
||||
attachment = Attachment.find(json['attachment_id'])
|
||||
expect(@course.short_name).to eq(File.basename(attachment.filename.split("-").last, ".csv"))
|
||||
expect(File.basename(attachment.filename.split("-").last, ".csv")).to eq("ENG__101")
|
||||
end
|
||||
|
||||
it "the CSV filename starts with YYYY-MM-DDTHHMM" do
|
||||
|
|
Loading…
Reference in New Issue