|
19 | 19 | let(:date) { Date.iso8601 "2020-01-01T00:00" } |
20 | 20 |
|
21 | 21 | it "aborts when the user is not found" do |
22 | | - expect { task.invoke("John Doe", organisation.name, date.iso8601) } |
| 22 | + expect { task.invoke("John Doe", organisation.name, date.iso8601, "crown") } |
23 | 23 | .to raise_error(ActiveRecord::RecordNotFound, /Couldn't find User/) |
24 | 24 | end |
25 | 25 |
|
26 | 26 | it "aborts when the organisation is not found" do |
27 | | - expect { task.invoke(user.email, "GDS", date.iso8601) } |
| 27 | + expect { task.invoke(user.email, "GDS", date.iso8601, "crown") } |
28 | 28 | .to raise_error(ActiveRecord::RecordNotFound, /Couldn't find Organisation/) |
29 | 29 | end |
30 | 30 |
|
31 | 31 | it "aborts when the agreed at date is not a valid date" do |
32 | | - expect { task.invoke(user.email, organisation.name, "not a date") } |
| 32 | + expect { task.invoke(user.email, organisation.name, "not a date", "crown") } |
33 | 33 | .to raise_error(Date::Error, /invalid date/) |
34 | 34 | end |
35 | 35 |
|
36 | 36 | it "creates an MOU signature" do |
37 | 37 | freeze_time do |
38 | | - expect { task.invoke(user.email, organisation.name, date.iso8601) } |
| 38 | + expect { task.invoke(user.email, organisation.name, date.iso8601, "crown") } |
39 | 39 | .to change(MouSignature, :count).by(1) |
40 | 40 | .and output(/Added MOU signature for User: A Person and Organisation: Government Digital Service signed at: 2020-01-01 00:00/).to_stdout |
41 | 41 |
|
42 | | - expect(MouSignature.last).to have_attributes(user:, organisation:, created_at: date, updated_at: Time.zone.now) |
| 42 | + expect(MouSignature.last).to have_attributes( |
| 43 | + user:, |
| 44 | + organisation:, |
| 45 | + created_at: date, |
| 46 | + updated_at: Time.zone.now, |
| 47 | + agreement_type: "crown", |
| 48 | + ) |
| 49 | + end |
| 50 | + end |
| 51 | + |
| 52 | + it "creates a non-crown MOU signature" do |
| 53 | + freeze_time do |
| 54 | + expect { task.invoke(user.email, organisation.name, date.iso8601, "non_crown") } |
| 55 | + .to change(MouSignature, :count).by(1) |
| 56 | + .and output(/Added MOU signature for User: A Person and Organisation: Government Digital Service signed at: 2020-01-01 00:00/).to_stdout |
| 57 | + |
| 58 | + expect(MouSignature.last).to have_attributes( |
| 59 | + user:, |
| 60 | + organisation:, |
| 61 | + created_at: date, |
| 62 | + updated_at: Time.zone.now, |
| 63 | + agreement_type: "non_crown", |
| 64 | + ) |
43 | 65 | end |
44 | 66 | end |
45 | 67 | end |
|
0 commit comments