@@ -45,7 +45,7 @@ def attachment_json(attachment)
4545 local_storage!
4646 # step 1, preflight
4747 json = preflight ( { :name => filename } )
48- attachment = Attachment . last ( :order => : id)
48+ attachment = Attachment . order ( : id) . last
4949 exemption_string = has_query_exemption? ? ( "?quota_exemption=" + attachment . quota_exemption_key ) : ""
5050 json [ 'upload_url' ] . should == "http://www.example.com/files_api#{ exemption_string } "
5151
@@ -56,7 +56,7 @@ def attachment_json(attachment)
5656 post_params = json [ "upload_params" ] . merge ( { "file" => tmpfile } )
5757 send_multipart ( json [ "upload_url" ] , post_params )
5858
59- attachment = Attachment . last ( :order => : id)
59+ attachment = Attachment . order ( : id) . last
6060 attachment . should be_deleted
6161 exemption_string = has_query_exemption? ? ( "quota_exemption=" + attachment . quota_exemption_key + "&" ) : ""
6262 response . should redirect_to ( "http://www.example.com/api/v1/files/#{ attachment . id } /create_success?#{ exemption_string } uuid=#{ attachment . uuid } " )
@@ -98,7 +98,7 @@ def attachment_json(attachment)
9898 # step 1, preflight
9999 json = preflight ( { :name =>
5781
span> filename } )
100100 json [ 'upload_url' ] . should == "http://no-bucket.s3.amazonaws.com/"
101- attachment = Attachment . last ( :order => : id)
101+ attachment = Attachment . order ( : id) . last
102102 redir = json [ 'upload_params' ] [ 'success_action_redirect' ]
103103 exemption_string = has_query_exemption? ? ( "quota_exemption=" + attachment . quota_exemption_key + "&" ) : ""
104104 redir . should == "http://www.example.com/api/v1/files/#{ attachment . id } /create_success?#{ exemption_string } uuid=#{ attachment . uuid } "
@@ -130,7 +130,7 @@ def attachment_json(attachment)
130130 local_storage!
131131 # step 1, preflight
132132 json = preflight ( { :name => filename , :size => 20 , :url => "http://www.example.com/images/delete.png" } )
133- attachment = Attachment . last ( :order => : id)
133+ attachment = Attachment . order ( : id) . last
134134 attachment . file_state . should == 'deleted'
135135 status_url = json [ 'status_url' ]
136136 status_url . should == "http://www.example.com/api/v1/files/#{ attachment . id } /#{ attachment . uuid } /status"
@@ -158,7 +158,7 @@ def attachment_json(attachment)
158158 local_storage!
159159 # step 1, preflight
160160 json = preflight ( { :name => filename , :size => 20 , :url => '#@$YA#Y#AGWREG' } )
161- attachment = Attachment . last ( :order => : id)
161+ attachment = Attachment . order ( : id) . last
162162 json [ 'status_url' ] . should == "http://www.example.com/api/v1/files/#{ attachment . id } /#{ attachment . uuid } /status"
163163
164164 # step 2, download
@@ -175,7 +175,7 @@ def attachment_json(attachment)
175175 local_storage!
176176 # step 1, preflight
177177 json = preflight ( { :name => filename , :size => 20 , :url => '/images/delete.png' } )
178- attachment = Attachment . last ( :order => : id)
178+ attachment = Attachment . order ( : id) . last
179179 json [ 'status_url' ] . should == "http://www.example.com/api/v1/files/#{ attachment . id } /#{ attachment . uuid } /status"
180180
181181 # step 2, download
@@ -194,7 +194,7 @@ def attachment_json(attachment)
194194 # step 1, preflight
195195 Canvas ::HTTP . expects ( :get ) . with ( url ) . yields ( FakeHttpResponse . new ( 404 ) )
196196 json = preflight ( { :name => filename , :size => 20 , :url => url } )
197- attachment = Attachment . last ( :order => : id)
197+ attachment = Attachment . order ( : id) . last
198198 json [ 'status_url' ] . should == "http://www.example.com/api/v1/files/#{ attachment . id } /#{ attachment . uuid } /status"
199199
200200 # step 2, download
@@ -213,7 +213,7 @@ def attachment_json(attachment)
213213 # step 1, preflight
214214 Canvas ::HTTP . expects ( :get ) . with ( url ) . raises ( Timeout ::Error )
215215 json = preflight ( { :name => filename , :size => 20 , :url => url } )
216- attachment = Attachment . last ( :order => : id)
216+ attachment = Attachment . order ( : id) . last
217217 json [ 'status_url' ] . should == "http://www.example.com/api/v1/files/#{ attachment . id } /#{ attachment . uuid } /status"
218218
219219 # step 2, download
@@ -232,7 +232,7 @@ def attachment_json(attachment)
232232 # step 1, preflight
233233 Canvas ::HTTP . expects ( :get ) . with ( url ) . raises ( Canvas ::HTTP ::TooManyRedirectsError )
234234 json = preflight ( { :name => filename , :size => 20 , :url => url } )
235- attachment = Attachment . last ( :order => : id)
235+ attachment = Attachment . order ( : id) . last
236236 attachment . workflow_state . should == 'unattached'
237237 json [ 'status_url' ] . should == "http://www.example.com/api/v1/files/#{ attachment . id } /#{ attachment . uuid } /status"
238238
@@ -256,21 +256,21 @@ def run_download_job
256256
257257 it "should allow specifying a folder with deprecated argument name" do
258258 preflight ( { :name => "with_path.txt" , :folder => "files/a/b/c/mypath" } )
259- attachment = Attachment . last ( :order => : id)
259+ attachment = Attachment . order ( : id) . last
260260 attachment . folder . should == Folder . assert_path ( "/files/a/b/c/mypath" , context )
261261 end
262262
263263 it "should allow specifying a folder" do
264264 preflight ( { :name => "with_path.txt" , :parent_folder_path => "files/a/b/c/mypath" } )
265- attachment = Attachment . last ( :order => : id)
265+ attachment = Attachment . order ( : id) . last
266266 attachment . folder . should == Folder . assert_path ( "/files/a/b/c/mypath" , context )
267267 end
268268
269269 it "should allow specifying a parent folder by id" do
270270 root = Folder . root_folders ( context ) . first
271271 sub = root . sub_folders . create! ( :name => "folder1" , :context => context )
272272 preflight ( { :name => "with_path.txt" , :parent_folder_id => sub . id . to_param } )
273- attachment = Attachment . last ( :order => : id)
273+ attachment = Attachment . order ( : id) . last
274274 attachment . folder_id . should == sub . id
275275 end
276276
@@ -279,7 +279,7 @@ def run_download_job
279279 @folder . should be_present
280280 @folder . should be_visible
281281 preflight ( { :name => "my_essay.doc" , :folder => "files/a/b/c/mypath" } )
282- attachment = Attachment . last ( :order => : id)
282+ attachment = Attachment . order ( : id) . last
283283 attachment . folder . should == @folder
284284 end
285285
@@ -296,7 +296,7 @@ def run_download_job
296296 send_multipart ( json [ "upload_url" ] , post_params )
297297 post response [ 'Location' ] , { } , { 'Authorization' => "Bearer #{ access_token_for_user @user } " }
298298 response . should be_success
299- attachment = Attachment . last ( :order => : id)
299+ attachment = Attachment . order ( : id) . last
300300 a1 . reload . should be_deleted
301301 attachment . reload . should be_available
302302 attachment . display_name . should == "test.txt"
@@ -309,7 +309,7 @@ def run_download_job
309309 @folder = Folder . assert_path ( "test" , context )
310310 a1 = Attachment . create! ( :folder => @folder , :context => context , :filename => "test.txt" , :uploaded_data => StringIO . new ( "first" ) )
311311 json = preflight ( { :name => "test.txt" , :folder => "test" , :url => "http://www.example.com/test" } )
312- attachment = Attachment . last ( :order => : id)
312+ attachment = Attachment . order ( : id) . last
313313 Canvas ::HTTP . expects ( :get ) . with ( "http://www.example.com/test" ) . yields ( FakeHttpResponse . new ( 200 , "second" ) )
314314 run_jobs
315315
@@ -333,7 +333,7 @@ def run_download_job
333333 send_multipart ( json [ "upload_url" ] , post_params )
334334 post response [ 'Location' ] , { } , { 'Authorization' => "Bearer #{ access_token_for_user @user } " }
335335 response . should be_success
336- attachment = Attachment . last ( :order => : id)
336+ attachment = Attachment . order ( : id) . last
337337 a1 . reload . should be_available
338338 attachment . reload . should be_available
339339 a1 . display_name . should == "test.txt"
@@ -346,7 +346,7 @@ def run_download_job
346346 @folder = Folder . assert_path ( "test" , context )
347347 a1 = Attachment . create! ( :folder => @folder , :context => context , :filename => "test.txt" , :uploaded_data => StringIO . new ( "first" ) )
348348 json = preflight ( { :name => "test.txt" , :folder => "test" , :on_duplicate => 'rename' , :url => "http://www.example.com/test" } )
349- attachment = Attachment . last ( :order => : id)
349+ attachment = Attachment . order ( : id) . last
350350 Canvas ::HTTP . expects ( :get ) . with ( "http://www.example.com/test" ) . yields ( FakeHttpResponse . new ( 200 , "second" ) )
351351 run_jobs
352352
@@ -364,7 +364,7 @@ def run_download_job
364364 json = preflight ( { :name => "test.txt" , :folder => "test" , :on_duplicate => 'rename' } )
365365
366366 redir = json [ 'upload_params' ] [ 'success_action_redirect' ]
367- attachment = Attachment . last ( :order => : id)
367+ attachment = Attachment . order ( : id) . last
368368 AWS ::S3 ::S3Object . any_instance . expects ( :head ) . returns ( {
369369 :content_type => 'application/msword' ,
370370 :content_length => 1234 ,
@@ -387,7 +387,7 @@ def run_download_job
387387 @context . write_attribute ( :storage_quota , 5 . megabytes )
388388 @context . save!
389389 json = preflight ( { :name => "test.txt" , :size => 3 . megabytes } )
390- attachment = Attachment . last ( :order => : id)
390+ attachment = Attachment . order ( : id) . last
391391 attachment . workflow_state . should == 'unattached'
392392 attachment . filename . should == 'test.txt'
393393 end
@@ -458,7 +458,7 @@ def run_download_job
458458 @context . save!
459459 json = preflight ( { :name => "test.txt" , :url => "http://www.example.com/test" } )
460460 status_url = json [ 'status_url' ]
461- attachment = Attachment . last ( :order => : id)
461+ attachment = Attachment . order ( : id) . last
462462 Canvas ::HTTP . expects ( :get ) . with ( "http://www.example.com/test" ) . yields ( FakeHttpResponse . new ( 200 , ( " " * 2 . megabytes ) ) )
463463 run_jobs
464464
@@ -474,15 +474,15 @@ def run_download_job
474474 @context . write_attribute ( :storage_quota , 0 )
475475 @context . save!
476476 json = preflight ( { :name => "test.txt" , :size => 1 . megabyte } )
477- attachment = Attachment . last ( :order => : id)
477+ attachment = Attachment . order ( : id) . last
478478 json [ 'upload_url' ] . should match ( /#{ attachment . quota_exemption_key } / )
479479 end
480480 it "should ignore context-related quotas in preflight" do
481481 s3_storage!
482482 @context . write_attribute ( :storage_quota , 0 )
483483 @context . save!
484484 json = preflight ( { :name => "test.txt" , :size => 1 . megabyte } )
485- attachment = Attachment . last ( :order => : id)
485+ attachment = Attachment . order ( : id) . last
486486 json [ 'upload_params' ] [ 'success_action_redirect' ] . should match ( /#{ attachment . quota_exemption_key } / )
487487 end
488488end
0 commit comments