|
3 | 3 | RSpec.describe SubmissionCompletion do |
4 | 4 | describe '#perform' do |
5 | 5 | let(:complete_submission) { SubmissionCompletion.new(submission) } |
| 6 | + let(:task) { FactoryBot.create(:task, status: :in_progress) } |
6 | 7 |
|
7 | 8 | context 'given an "in review" submission' do |
8 | 9 | context 'with validated entries' do |
9 | | - let(:submission) { FactoryBot.create(:submission_with_validated_entries, aasm_state: 'in_review') } |
| 10 | + let(:submission) { FactoryBot.create(:submission_with_validated_entries, aasm_state: 'in_review', task: task) } |
10 | 11 |
|
11 | 12 | it 'transitions the submission to completed' do |
12 | 13 | complete_submission.perform! |
13 | 14 |
|
14 | 15 | expect(submission).to be_completed |
15 | 16 | end |
| 17 | + |
| 18 | + it 'transitions the task to completed' do |
| 19 | + complete_submission.perform! |
| 20 | + |
| 21 | + expect(task).to be_completed |
| 22 | + end |
16 | 23 | end |
17 | 24 |
|
18 | 25 | context 'with some invalid entries' do |
19 | | - let(:submission) { FactoryBot.create(:submission_with_invalid_entries) } |
| 26 | + let(:submission) { FactoryBot.create(:submission_with_invalid_entries, task: task) } |
20 | 27 |
|
21 | 28 | it 'leaves the submission in the "in_review" state' do |
22 | 29 | expect { complete_submission.perform! }.not_to change { submission.aasm_state } |
23 | 30 | end |
| 31 | + |
| 32 | + it 'leaves the task in the "in_progress" state' do |
| 33 | + expect { complete_submission.perform! }.not_to change { task.status } |
| 34 | + end |
24 | 35 | end |
25 | 36 | end |
26 | 37 |
|
27 | 38 | context 'given a "processing" submission' do |
28 | | - let(:submission) { FactoryBot.create(:submission_with_unprocessed_entries, aasm_state: :processing) } |
| 39 | + let(:submission) { FactoryBot.create(:submission_with_unprocessed_entries, aasm_state: :processing, task: task) } |
29 | 40 |
|
30 | 41 | it 'leaves the submission in its current state' do |
31 | 42 | expect { complete_submission.perform! }.not_to change { submission.aasm_state } |
|
0 commit comments