@@ -105,24 +105,24 @@ def zipped_files_for_user(user=nil, check_user=true)
105105 names = [ ]
106106 @attachment . reload
107107 Zip ::ZipFile . foreach ( @attachment . full_filename ) { |f | names << f . name if f . file? }
108- names
108+ names . sort
109109 end
110110
111111 context "in a private course" do
112112 it "should give logged in students some files" do
113- zipped_files_for_user ( @user ) . should == [ 'visible.png' , 'visible/sub-vis.png' ]
113+ zipped_files_for_user ( @user ) . should == [ 'visible.png' , 'visible/sub-vis.png' ] . sort
114114 end
115115
116116 it "should give logged in teachers all files" do
117- zipped_files_for_user ( @teacher ) . should == [ "locked/sub-locked-vis.png" , "hidden/sub-hidden.png" , "hidden.png" , "visible.png" , "visible/sub-locked.png" , "visible/sub-vis.png" , "locked.png" ]
117+ zipped_files_for_user ( @teacher ) . should == [ "locked/sub-locked-vis.png" , "hidden/sub-hidden.png" , "hidden.png" , "visible.png" , "visible/sub-locked.png" , "visible/sub-vis.png" , "locked.png" ] . sort
118118 end
119119
120120 it "should give logged out people no files" do
121121 zipped_files_for_user ( nil ) . should == [ ]
122122 end
123123
124124 it "should give all files if check_user=false" do
125- zipped_files_for_user ( nil , false ) . should == [ "locked/sub-locked-vis.png" , "hidden/sub-hidden.png" , "hidden.png" , "visible.png" , "visible/sub-locked.png" , "visible/sub-vis.png" , "locked.png" ]
125+ zipped_files_for_user ( nil , false ) . should == [ "locked/sub-locked-vis.png" , "hidden/sub-hidden.png" , "hidden.png" , "visible.png" , "visible/sub-locked.png" , "visible/sub-vis.png" , "locked.png" ] . sort
126126 end
127127 end
128128
@@ -133,19 +133,19 @@ def zipped_files_for_user(user=nil, check_user=true)
133133 end
134134
135135 it "should give logged in students some files" do
136- zipped_files_for_user ( @user ) . should == [ 'visible.png' , 'visible/sub-vis.png' ]
136+ zipped_files_for_user ( @user ) . should == [ 'visible.png' , 'visible/sub-vis.png' ] . sort
137137 end
138138
139139 it "should give logged in teachers all files" do
140- zipped_files_for_user ( @teacher ) . should == [ "locked/sub-locked-vis.png" , "hidden/sub-hidden.png" , "hidden.png" , "visible.png" , "visible/sub-locked.png" , "visible/sub-vis.png" , "locked.png" ]
140+ zipped_files_for_user ( @teacher ) . should == [ "locked/sub-locked-vis.png" , "hidden/sub-hidden.png" , "hidden.png" , "visible.png" , "visible/sub-locked.png" , "visible/sub-vis.png" , "locked.png" ] . sort
141141 end
142142
143143 it "should give logged out people the same thing as students" do
144- zipped_files_for_user ( nil ) . should == [ 'visible.png' , 'visible/sub-vis.png' ]
144+ zipped_files_for_user ( nil ) . should == [ 'visible.png' , 'visible/sub-vis.png' ] . sort
145145 end
146146
147147 it "should give all files if check_user=false" do
148- zipped_files_for_user ( nil , false ) . should == [ "locked/sub-locked-vis.png" , "hidden/sub-hidden.png" , "hidden.png" , "visible.png" , "visible/sub-locked.png" , "visible/sub-vis.png" , "locked.png" ]
148+ zipped_files_for_user ( nil , false ) . should == [ "locked/sub-locked-vis.png" , "hidden/sub-hidden.png" , "hidden.png" , "visible.png" , "visible/sub-locked.png" , "visible/sub-vis.png" , "locked.png" ] . sort
149149 end
150150 end
151151 end
@@ -161,5 +161,21 @@ def zipped_files_for_user(user=nil, check_user=true)
161161 ContentZipper . process_attachment ( attachment , @user )
162162 attachment . workflow_state . should == 'zipped'
163163 end
164+
165+ it "should use the display name" do
166+ course_with_student ( :active_all => true )
167+ folder = Folder . root_folders ( @course ) . first
168+ attachment_model ( :uploaded_data => stub_png_data ( 'hidden.png' ) , :content_type => 'image/png' , :folder => folder , :display_name => 'otherfile.png' )
169+ attachment = Attachment . new ( :display_name => 'my_download.zip' )
170+ attachment . user_id = @user . id
171+ attachment . workflow_state = 'to_be_zipped'
172+ attachment . context = folder
173+ attachment . save!
174+ ContentZipper . process_attachment ( attachment , @user )
175+ attachment . reload
176+ names = [ ]
177+ Zip ::ZipFile . foreach ( attachment . full_filename ) { |f | names << f . name if f . file? }
178+ names . should == [ 'otherfile.png' ]
179+ end
164180 end
165181end
0 commit comments