Allow for non-existent event types in Webhooks::Outgoing::Endpoint#event_types
#983
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #654
The Set Up
Let's say you had created a
Widget
model, and had addedwidget.*
events toconfig/models/webhooks/outgoing/event_types.yml
:And then you (or one of your users) sets up an Outgoing Webhook using one of the widget events. Effectively this:
Then at a later time you decide that the
Widget
model was a bad idea, and so you remove it fromevent_types.yml
.Old Behavior
Previously, if you then called
event_types
on thatendpoint
we'd raise anActiveHash::RecordNotFound
error:New Behavior
Now if you call
event_types
on thatendpoint
we'll return anActiveRecord::Relation
ofWebhooks::Outgoing::EventType
objects for the still-goodevent_type_ids
for the endpoint. Sincewidget.created
is no longer a valid type, it won't show up in theevent_types
array and we won't raise an error.Possible breaking change
Previously
event_types
would return anArray
ofWebhooks::Outgoing::EventType
objects.Now it returns an
ActiveRecord::Relation
ofWebhooks::Outgoing::EventType
objects.