Fix production Basecamp webhook format

This commit is contained in:
Stanko K.R.
2025-10-01 14:36:45 +02:00
parent da9dcc7e31
commit 9ddfe4d803
3 changed files with 7 additions and 5 deletions
+1 -1
View File
@@ -50,7 +50,7 @@ class Webhook < ApplicationRecord
end
def renderer
@renderer ||= ApplicationController.renderer.new
@renderer ||= ApplicationController.renderer.new(script_name: "/#{tenant}", https: !Rails.env.local?)
end
def for_basecamp?
+3 -1
View File
@@ -116,6 +116,8 @@ class Webhook::Delivery < ApplicationRecord
def content_type
if webhook.for_campfire?
"text/html"
elsif webhook.for_basecamp?
"application/x-www-form-urlencoded"
else
"application/json"
end
@@ -123,7 +125,7 @@ class Webhook::Delivery < ApplicationRecord
def payload
@payload ||= if webhook.for_basecamp?
{ line: { content: render_payload(formats: :html) } }.to_json
{ content: render_payload(formats: :html) }.to_query
elsif webhook.for_campfire?
render_payload(formats: :html)
elsif webhook.for_slack?
+3 -3
View File
@@ -126,9 +126,9 @@ class Webhook::DeliveryTest < ActiveSupport::TestCase
request_stub = stub_request(:post, webhook.url)
.with do |request|
body = JSON.parse(request.body)
body.key?("line") && body["line"].key?("content") && body["line"]["content"].present? &&
request.headers["Content-Type"] == "application/json"
body = CGI.parse(request.body)
body.key?("content") && body["content"].first.present? &&
request.headers["Content-Type"] == "application/x-www-form-urlencoded"
end
.to_return(status: 200)