@@ -33,7 +33,19 @@ def setup_thesis
3333 end
3434
3535 test 'creates multiple SIPs' do
36- theses = [ setup_thesis , theses ( :published ) ]
36+ thesis_one = setup_thesis
37+ thesis_two = theses ( :engineer )
38+ assert_equal 0 , thesis_one . submission_information_packages . count
39+ assert_equal 0 , thesis_two . submission_information_packages . count
40+
41+ theses = [ thesis_one , thesis_two ]
42+ PreservationSubmissionJob . perform_now ( theses )
43+ assert_equal 1 , thesis_one . submission_information_packages . count
44+ assert_equal 1 , thesis_two . submission_information_packages . count
45+
46+ PreservationSubmissionJob . perform_now ( theses )
47+ assert_equal 2 , thesis_one . submission_information_packages . count
48+ assert_equal 2 , thesis_two . submission_information_packages . count
3749 end
3850
3951 test 'updates preservation_status to "preserved" after successfully processing a thesis' do
@@ -51,15 +63,21 @@ def setup_thesis
5163 end
5264 end
5365
54- test 'rescues exceptions by updating preservation_status to "error"' do
55- thesis = theses ( :one )
56- PreservationSubmissionJob . perform_now ( [ thesis ] )
57- assert_equal 'error' , thesis . submission_information_packages . last . preservation_status
66+ test 'throws exceptions when a thesis is unbaggable' do
67+ assert_raises StandardError do
68+ PreservationSubmissionJob . perform_now ( [ theses [ :one ] ] )
69+ end
70+
71+ assert_nothing_raised do
72+ PreservationSubmissionJob . perform_now ( [ setup_thesis ] )
73+ end
5874 end
5975
60- test 'does not update preserved_at if the job enters an error state' do
76+ test 'does not create a SIP if the job enters an error state' do
6177 thesis = theses ( :one )
78+ assert_empty thesis . submission_information_packages
79+
6280 PreservationSubmissionJob . perform_now ( [ thesis ] )
63- assert_nil thesis . submission_information_packages . last . preserved_at
81+ assert_empty thesis . submission_information_packages
6482 end
6583end
0 commit comments