Skip to content

Commit 1bf4418

Browse files
committed
fix submissions.zip filenames frd (and fix broken spec)
fixes CNVS-7636 This fixes a failing spec and also resolves some remaining edge cases where _\d+_ could have inappropriately happened. Test plan: * Make an assignment with students named something like: - student 1 - student 2! * Download the submissions zip * Make sure uploading them works (their submissions are not ignored) Change-Id: Iad0de754f618a68f815780b89df0aaa9ea7afd16 Reviewed-on: https://gerrit.instructure.com/23490 QA-Review: Amber Taniuchi <amber@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Simon Williams <simon@instructure.com> Product-Review: Cameron Matheson <cameron@instructure.com>
1 parent d28b775 commit 1bf4418

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

lib/content_zipper.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ def zip_assignment(zip_attachment, assignment)
9292
users_name = students[submission.user_id].sortable_name
9393
# necessary because we use /_\d+_/ to infer the user/attachment
9494
# ids when teachers upload graded submissions
95-
users_name.gsub! /[_ ](\d+)[_ ]/, '-\1-'
95+
users_name.gsub! /_(\d+)_/, '-\1-'
9696

97-
filename = users_name + (submission.late? ? " LATE-" : "-") + submission.user_id.to_s
98-
filename = filename.gsub(/ /, "_").gsub(/[^-\w]/, "").downcase
97+
filename = users_name + (submission.late? ? " LATE_" : "_") + submission.user_id.to_s
98+
filename = filename.gsub(/ /, "-").gsub(/[^-\w]/, "-").downcase
9999
content = nil
100100
if submission.submission_type == "online_upload"
101101
submission.attachments.each do |attachment|

spec/lib/content_zipper_spec.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,23 @@
2424
s1, s2 = 2.times.map { course_with_student ; @student }
2525
s1.update_attribute :sortable_name, 'some_999_, _1234_guy'
2626
s2.update_attribute :sortable_name, 'other 567, guy 8'
27-
[s1, s2].each { |s| submission_model(:user => s) }
27+
[s1, s2].each { |s|
28+
submission_model user: s, assignment: @assignment, body: "blah"
29+
}
2830
attachment = Attachment.new(:display_name => 'my_download.zip')
2931
attachment.user = @teacher
3032
attachment.workflow_state = 'to_be_zipped'
3133
attachment.context = @assignment
3234
attachment.save!
3335
ContentZipper.process_attachment(attachment, @teacher)
3436
expected_file_patterns = [
35-
/other-567-_guy-8-/,
36-
/some-999-_-1234-guy/,
37+
/other-567--guy-8/,
38+
/some-999----1234-guy/,
3739
]
3840
Zip::ZipFile.foreach(attachment.reload.full_filename).each { |f|
3941
f.name.should =~ expected_file_patterns.shift
4042
}
43+
expected_file_patterns.should be_empty
4144
end
4245

4346
it "should zip up online_url submissions" do
@@ -54,7 +57,7 @@
5457
attachment.workflow_state.should == 'zipped'
5558
Zip::ZipFile.foreach(attachment.full_filename) do |f|
5659
if f.file?
57-
f.name.should =~ /some-999-_-1234-guy/
60+
f.name.should =~ /some-999----1234-guy/
5861
f.get_input_stream.read.should match(%r{This submission was a url, we&#39;re taking you to the url link now.})
5962
f.get_input_stream.read.should be_include("http://www.instructure.com/")
6063
end
@@ -116,7 +119,7 @@
116119

117120
ContentZipper.process_attachment(attachment, @teacher)
118121
sub_count = 0
119-
expected_file_names = [/group_0/, /group_1/]
122+
expected_file_names = [/group-0/, /group-1/]
120123
Zip::ZipFile.foreach(attachment.full_filename) do |f|
121124
f.name.should =~ expected_file_names.shift
122125
sub_count += 1

0 commit comments

Comments
 (0)