feat: Add inbox webhook events (#8006)

- Add webhook events for inbox creation/updation.
- Right now, the feature is added under a feature_flag. It is not available by default on all installations.
This commit is contained in:
Pranav Raj S
2023-09-28 15:28:10 -07:00
committed by GitHub
parent 12a64f1b10
commit fd633e1613
8 changed files with 165 additions and 1 deletions

View File

@@ -210,6 +210,34 @@ RSpec.describe Inbox do
expect(inbox.portal).to eq(portal)
end
it 'sends the inbox_created event if ENABLE_INBOX_EVENTS is true' do
with_modified_env ENABLE_INBOX_EVENTS: 'true' do
channel = inbox.channel
channel.update(widget_color: '#fff')
expect(Rails.configuration.dispatcher).to have_received(:dispatch)
.with(
'inbox.updated',
kind_of(Time),
inbox: inbox,
changed_attributes: kind_of(Object)
)
end
end
it 'sends the inbox_created event if ENABLE_INBOX_EVENTS is false' do
channel = inbox.channel
channel.update(widget_color: '#fff')
expect(Rails.configuration.dispatcher).not_to have_received(:dispatch)
.with(
'inbox.updated',
kind_of(Time),
inbox: inbox,
changed_attributes: kind_of(Object)
)
end
it 'resets cache key if there is an update in the channel' do
channel = inbox.channel
channel.update(widget_color: '#fff')