|
26 | 26 |
|
27 | 27 | describe "#save" do |
28 | 28 | let_once(:create_service) do |
29 | | - EpubExports::CreateService.new(@course, @student) |
| 29 | + EpubExports::CreateService.new(@course, @student, :epub_export) |
30 | 30 | end |
31 | 31 |
|
32 | 32 | it "should send save & export to epub_export" do |
33 | | - expect(create_service.epub_export.new_record?).to be_truthy, 'precondition' |
34 | | - create_service.epub_export.expects(:export).once.returns(nil) |
| 33 | + expect(create_service.offline_export.new_record?).to be_truthy, 'precondition' |
| 34 | + create_service.offline_export.expects(:export).once.returns(nil) |
35 | 35 | expect(create_service.save).to be_truthy |
36 | | - expect(create_service.epub_export.new_record?).to be_falsey |
| 36 | + expect(create_service.offline_export.new_record?).to be_falsey |
37 | 37 | end |
38 | 38 | end |
39 | 39 |
|
40 | | - describe "#epub_export" do |
| 40 | + describe "#offline_export" do |
41 | 41 | context "when user has an active epub_export" do |
42 | 42 | before(:once) do |
43 | 43 | @epub_export = @course.epub_exports.create(user: @student) |
44 | 44 | @epub_export.export_without_send_later |
45 | | - @service = EpubExports::CreateService.new(@course, @student) |
| 45 | + @service = EpubExports::CreateService.new(@course, @student, :epub_export) |
46 | 46 | end |
47 | 47 |
|
48 | 48 | it "should return said epub_export" do |
49 | | - expect(@service.epub_export).to eq @epub_export |
| 49 | + expect(@service.offline_export).to eq @epub_export |
50 | 50 | end |
51 | 51 | end |
52 | 52 |
|
53 | 53 | context "when user has no active epub_exports" do |
54 | 54 | it "should return a new epub_export instance" do |
55 | | - service = EpubExports::CreateService.new(@course, @student) |
56 | | - expect(service.epub_export).to be_new_record |
| 55 | + service = EpubExports::CreateService.new(@course, @student, :epub_export) |
| 56 | + expect(service.offline_export).to be_new_record |
57 | 57 | end |
58 | 58 | end |
59 | 59 | end |
|
62 | 62 | context "when user has an active epub_export" do |
63 | 63 | before(:once) do |
64 | 64 | @course.epub_exports.create(user: @student).export_without_send_later |
65 | | - @service = EpubExports::CreateService.new(@course, @student) |
| 65 | + @service = EpubExports::CreateService.new(@course, @student, :epub_export) |
66 | 66 | end |
67 | 67 |
|
68 | 68 | it "should return true" do |
|
72 | 72 |
|
73 | 73 | context "when user doesn't have an active epub_export" do |
74 | 74 | it "should return true" do |
75 | | - service = EpubExports::CreateService.new(@course, @student) |
| 75 | + service = EpubExports::CreateService.new(@course, @student, :epub_export) |
76 | 76 | expect(service.already_running?).to be_falsey |
77 | 77 | end |
78 | 78 | end |
| 79 | + |
| 80 | + context "when user has an active epub_export and starts a web_zip_export" do |
| 81 | + before(:once) do |
| 82 | + @epub_export = @course.epub_exports.create(user: @student) |
| 83 | + @epub_export.export_without_send_later |
| 84 | + @service = EpubExports::CreateService.new(@course, @student, :web_zip_export) |
| 85 | + end |
| 86 | + |
| 87 | + it "should return false" do |
| 88 | + expect(@service.already_running?).to be_falsey |
| 89 | + end |
| 90 | + end |
79 | 91 | end |
80 | 92 | end |
0 commit comments