|
47 | 47 | expect(response.body).not_to include("99<br>")
|
48 | 48 | end
|
49 | 49 |
|
| 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 |
| 112 | + deleted_item = create(:item, organization: organization) |
| 113 | + travel(-1.day) do |
| 114 | + SnapshotEvent.create!( |
| 115 | + eventable: organization, |
| 116 | + organization_id: organization.id, |
| 117 | + event_time: Time.zone.now, |
| 118 | + data: EventTypes::Inventory.new( |
| 119 | + organization_id: organization.id, |
| 120 | + storage_locations: { |
| 121 | + storage_location.id => EventTypes::EventStorageLocation.new( |
| 122 | + id: storage_location.id, |
| 123 | + items: { |
| 124 | + item.id => EventTypes::EventItem.new(item_id: item.id, quantity: 0), |
| 125 | + item2.id => EventTypes::EventItem.new(item_id: item2.id, quantity: 0), |
| 126 | + deleted_item.id => EventTypes::EventItem.new(item_id: deleted_item.id, quantity: 0) |
| 127 | + } |
| 128 | + ), |
| 129 | + storage_location2.id => EventTypes::EventStorageLocation.new( |
| 130 | + id: storage_location2.id, |
| 131 | + items: { |
| 132 | + item.id => EventTypes::EventItem.new(item_id: item.id, quantity: 0), |
| 133 | + item2.id => EventTypes::EventItem.new(item_id: item2.id, quantity: 0), |
| 134 | + deleted_item.id => EventTypes::EventItem.new(item_id: deleted_item.id, quantity: 0) |
| 135 | + } |
| 136 | + ) |
| 137 | + } |
| 138 | + ) |
| 139 | + ) |
| 140 | + end |
| 141 | + deleted_id = deleted_item.id |
| 142 | + deleted_item.destroy |
| 143 | + subject |
| 144 | + expect(response.body).to include("Item1</a>") |
| 145 | + expect(response.body).to include("Item2</a>") |
| 146 | + expect(response.body).to include("Item #{deleted_id} (deleted)") |
| 147 | + end |
| 148 | + |
50 | 149 | context "with type filter" do
|
51 | 150 | let(:params) { {format: "html", filters: {by_type: "DonationEvent"}} }
|
52 | 151 |
|
|
0 commit comments