|
47 | 47 | expect(response.body).not_to include("99<br>") |
48 | 48 | end |
49 | 49 |
|
50 | | - it "should show deleted items without crashing" do |
| 50 | + it "should show deleted items on regular event without crashing" do |
| 51 | + deleted_item = create(:item, organization: organization) |
| 52 | + travel(-1.day) do |
| 53 | + SnapshotEvent.create!( |
| 54 | + eventable: organization, |
| 55 | + organization_id: organization.id, |
| 56 | + event_time: Time.zone.now, |
| 57 | + data: EventTypes::Inventory.new( |
| 58 | + organization_id: organization.id, |
| 59 | + storage_locations: { |
| 60 | + storage_location.id => EventTypes::EventStorageLocation.new( |
| 61 | + id: storage_location.id, |
| 62 | + items: { |
| 63 | + item.id => EventTypes::EventItem.new(item_id: item.id, quantity: 0), |
| 64 | + item2.id => EventTypes::EventItem.new(item_id: item2.id, quantity: 0) |
| 65 | + } |
| 66 | + ), |
| 67 | + storage_location2.id => EventTypes::EventStorageLocation.new( |
| 68 | + id: storage_location2.id, |
| 69 | + items: { |
| 70 | + item.id => EventTypes::EventItem.new(item_id: item.id, quantity: 0), |
| 71 | + item2.id => EventTypes::EventItem.new(item_id: item2.id, quantity: 0) |
| 72 | + } |
| 73 | + ) |
| 74 | + } |
| 75 | + ) |
| 76 | + ) |
| 77 | + donation = create(:donation, organization: organization) |
| 78 | + DonationEvent.create!( |
| 79 | + eventable: donation, |
| 80 | + organization_id: organization.id, |
| 81 | + event_time: Time.zone.now, |
| 82 | + data: EventTypes::InventoryPayload.new( |
| 83 | + items: [ |
| 84 | + EventTypes::EventLineItem.new(item_id: item.id, |
| 85 | + quantity: 0, |
| 86 | + item_value_in_cents: 5, |
| 87 | + from_storage_location: nil, |
| 88 | + to_storage_location: storage_location.id), |
| 89 | + EventTypes::EventLineItem.new(item_id: item2.id, |
| 90 | + quantity: 0, |
| 91 | + item_value_in_cents: 5, |
| 92 | + from_storage_location: nil, |
| 93 | + to_storage_location: storage_location.id), |
| 94 | + EventTypes::EventLineItem.new(item_id: deleted_item.id, |
| 95 | + quantity: 0, |
| 96 | + item_value_in_cents: 5, |
| 97 | + from_storage_location: nil, |
| 98 | + to_storage_location: storage_location.id) |
| 99 | + ] |
| 100 | + ) |
| 101 | + ) |
| 102 | + end |
| 103 | + deleted_id = deleted_item.id |
| 104 | + deleted_item.destroy |
| 105 | + subject |
| 106 | + expect(response.body).to include("Item1</a>") |
| 107 | + expect(response.body).to include("Item2</a>") |
| 108 | + expect(response.body).to include("Item #{deleted_id} (deleted)") |
| 109 | + end |
| 110 | + |
| 111 | + it "should show deleted items on snapshot without crashing" do |
51 | 112 | deleted_item = create(:item, organization: organization) |
52 | 113 | travel(-1.day) do |
53 | 114 | SnapshotEvent.create!( |
|
0 commit comments