mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FEATURE: webhooks support for mailgun
This commit is contained in:
parent
1caaf5208f
commit
116efffdaa
7 changed files with 129 additions and 4 deletions
34
spec/controllers/webhooks_controller_spec.rb
Normal file
34
spec/controllers/webhooks_controller_spec.rb
Normal file
|
@ -0,0 +1,34 @@
|
|||
require "rails_helper"
|
||||
|
||||
describe WebhooksController do
|
||||
|
||||
context "mailgun" do
|
||||
|
||||
|
||||
it "works" do
|
||||
SiteSetting.mailgun_api_key = "pubkey-8221462f0c915af3f6f2e2df7aa5a493"
|
||||
token = "705a8ccd2ce932be8e98c221fe701c1b4a0afcb8bbd57726de"
|
||||
|
||||
user = Fabricate(:user, email: "em@il.com")
|
||||
email_log = Fabricate(:email_log, user: user, bounce_key: SecureRandom.hex)
|
||||
return_path = "foo+verp-#{email_log.bounce_key}@bar.com"
|
||||
|
||||
$redis.del("mailgun_token_#{token}")
|
||||
$redis.del("bounce_score:#{user.email}:#{Date.today}")
|
||||
WebhooksController.any_instance.expects(:mailgun_verify).returns(true)
|
||||
|
||||
post :mailgun, "token" => token,
|
||||
"timestamp" => Time.now.to_i,
|
||||
"event" => "dropped",
|
||||
"message-headers" => [["Return-Path", return_path]]
|
||||
|
||||
expect(response).to be_success
|
||||
|
||||
email_log.reload
|
||||
expect(email_log.bounced).to eq(true)
|
||||
expect(email_log.user.user_stat.bounce_score).to eq(2)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue