Skip to content

Commit fdbdb05

Browse files
authored
Merge pull request #5430 from rubyforgood/fix-kits
Fix kits not updating
2 parents ff8c978 + 1876c4f commit fdbdb05

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

app/events/kit_allocate_event.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def self.event_line_items(kit, storage_location, quantity)
2020
end
2121

2222
def self.publish(kit, storage_location, quantity)
23-
create(
23+
create!(
2424
eventable: kit,
2525
group_id: "kit-allocate-#{kit.id}-#{SecureRandom.hex}",
2626
organization_id: kit.organization_id,

app/models/event.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class Event < ApplicationRecord
4545
def no_intervening_snapshot
4646
return if is_a?(SnapshotEvent)
4747
return unless eventable.respond_to?(:organization)
48+
return if eventable.is_a?(Kit)
4849

4950
intervening = SnapshotEvent.intervening(eventable)
5051
if intervening.present?

spec/events/inventory_aggregate_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@
385385
{item_id: item1.id, quantity: 10},
386386
{item_id: item2.id, quantity: 3}
387387
])
388+
# it should work even if snapshot is after the kit
389+
kit.update!(created_at: 1.week.ago)
390+
SnapshotEvent.publish(organization)
388391

389392
KitAllocateEvent.publish(kit, storage_location1.id, 2)
390393

0 commit comments

Comments
 (0)