forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgradebook_upload_spec.rb
More file actions
59 lines (53 loc) · 2.25 KB
/
Copy pathgradebook_upload_spec.rb
File metadata and controls
59 lines (53 loc) · 2.25 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
require_relative '../spec_helper'
describe GradebookUpload do
describe ".queue_from" do
let(:teacher_enrollment){ teacher_in_course }
let(:teacher){ teacher_enrollment.user }
let(:gradebook_course){ teacher_enrollment.course }
let(:attachment_data){ {dummy: "data"} }
before(:each) do
# actual attachment integration covered in gradebook_uploads_controller_spec;
# that means in the spec the dummy hash will be enqueued instead of a real attachment
# object
GradebookUpload.any_instance.stubs(attachments: stub(create!: attachment_data))
end
it "builds a progress object to track the import" do
progress = GradebookUpload.queue_from(gradebook_course, teacher, attachment_data)
expect(progress.workflow_state).to eq("queued")
expect(progress.tag).to eq("gradebook_upload")
expect(progress.context).to eq(gradebook_course)
end
it "queues a job to run the import" do
GradebookUpload.queue_from(gradebook_course, teacher, attachment_data)
job = Delayed::Job.last
expect(job.tag).to match(/GradebookImporter/)
end
it "stores the input data in an attachment on the gradebook upload" do
GradebookUpload.queue_from(gradebook_course, teacher, attachment_data)
job = Delayed::Job.last
expect(job.handler).to include("dummy: data")
end
it "creates a GradebookUpload object to represent the upload process" do
GradebookUpload.queue_from(gradebook_course, teacher, attachment_data)
upload = GradebookUpload.last
expect(upload.course).to eq(gradebook_course)
end
end
end