Skip to content

Commit

Permalink
fix: #246 bug object type root object is missing on webhook (#247)
Browse files Browse the repository at this point in the history
* fix: #246 add object type root key in webhook payload

* add spec to avoid regression
  • Loading branch information
jdenquin authored Jun 3, 2022
1 parent 1758c13 commit 2db5616
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/services/webhooks/base_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ def initialize(object)
def call
return unless current_organization&.webhook_url?

payload = object_serializer.serialize
payload = payload.merge(
payload = {
webhook_type: webhook_type,
object_type: object_type,
)
object_type => object_serializer.serialize,
}

http_client = LagoHttpClient::Client.new(current_organization.webhook_url)
headers = generate_headers(payload)
Expand Down
10 changes: 10 additions & 0 deletions spec/services/webhooks/invoices_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@
end
end

it 'builds payload with the object type root key' do
webhook_invoice_service.call

expect(LagoHttpClient::Client).to have_received(:new)
.with(organization.webhook_url)
expect(lago_client).to have_received(:post) do |payload|
expect(payload['invoice']).to be_present
end
end

context 'without webhook_url' do
let(:webhook_url) { nil }

Expand Down

0 comments on commit 2db5616

Please sign in to comment.