diff --git a/lib/mailgun/webhooks/webhooks.rb b/lib/mailgun/webhooks/webhooks.rb index 8c56166..5a20002 100644 --- a/lib/mailgun/webhooks/webhooks.rb +++ b/lib/mailgun/webhooks/webhooks.rb @@ -84,7 +84,8 @@ def create(domain, action, url = '') # Returns true or false # :nocov: %i[create_all add_all_webhooks].each do |method| - define_method(method) do |domain| + define_method(method) do |domain, url| + url ||= '' warn("`#{method}` method will be deprecated in future versions of Mailgun. Please use `create` instead.") ACTIONS.each do |action| diff --git a/spec/unit/webhooks_spec.rb b/spec/unit/webhooks_spec.rb new file mode 100644 index 0000000..3cdf9b9 --- /dev/null +++ b/spec/unit/webhooks_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Mailgun::Webhooks do + let(:client) { double(:client) } + let(:webhooks) { described_class.new(client) } + let(:domain) { 'example.com' } + let(:url) { 'https://example.com/mailgun/events' } + + %i[create_all add_all_webhooks].each do |method| + describe "##{method}" do + it 'creates every webhook action with the provided URL' do + described_class::ACTIONS.each do |action| + expect(webhooks).to receive(:create).with(domain, action, url).ordered + end + + expect { webhooks.public_send(method, domain, url) } + .to output(/`#{method}` method will be deprecated/).to_stderr + end + end + end +end