forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent_zipper_spec.rb
39 lines (34 loc) · 1.4 KB
/
content_zipper_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe ContentZipper do
# Note that EportfoliosController#export,
# SubmissionsController#submission_zip, and FoldersController#download are
# all ALMOST exactly the same code, copied and pasted with slight changes.
#
# This really needs to get refactored at some point.
def grab_zip
expect { yield }.to change(Delayed::Job, :count).by(1)
response.should be_success
attachment_id = json_parse['attachment']['id']
attachment_id.should be_present
a = Attachment.find attachment_id
a.should be_to_be_zipped
# a second query should just return status
expect { yield }.to change(Delayed::Job, :count).by(0)
response.should be_success
json_parse['attachment']['id'].should == a.id
end
context "submission zips" do
it "should schedule a job on the first request, and then respond with progress updates" do
course_with_teacher_logged_in(:active_all => true)
submission_model(:course => @course)
grab_zip { get "/courses/#{@course.id}/assignments/#{@assignment.id}/submissions.json?zip=1&compile=1" }
end
end
context "eportfolio zips" do
it "should schedule a job on the first request, and then respond with progress updates" do
eportfolio_model
user_session(@user)
grab_zip { get "/eportfolios/#{@eportfolio.id}/export.json?compile=1" }
end
end
end