Fix production Basecamp webhook format
This commit is contained in:
@@ -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?
|
||||
|
||||
@@ -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?
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user