Handle GibbonError when Mailchimp api key was not set (#14695)
* When an api key was not set - handle gibbon error as mailchimp error see https://app.honeybadger.io/projects/72638/faults/73753178 It's possible the right answer is instead to either (1) not make the call at all (2) not log as a mailchimp error but treat distinctly * Only report error if GibbonError, don't attempt to resubscribe Separate the rescue blocks since resubscribing doesn't make sense if we're handling a gibbon error rather than a mailchimp error * Add test for gibbon error being raised (and rescued) Copied the existing test specifying that resubscribe is attempted on a raised mailchimp error. * Remove irrelevant resubscribe check - assert error is handled only
This commit is contained in:
parent
c946d0bf6b
commit
324265e24e
2 changed files with 11 additions and 0 deletions
|
|
@ -41,6 +41,8 @@ module Mailchimp
|
|||
)
|
||||
|
||||
success = true
|
||||
rescue Gibbon::GibbonError => e
|
||||
report_error(e)
|
||||
rescue Gibbon::MailChimpError => e
|
||||
# If user was previously subscribed, set their status to "pending"
|
||||
return resubscribe_to_newsletter if previously_subcribed?(e)
|
||||
|
|
|
|||
|
|
@ -90,6 +90,15 @@ RSpec.describe Mailchimp::Bot, type: :service do
|
|||
|
||||
expect(mailchimp_bot).to have_received(:resubscribe_to_newsletter)
|
||||
end
|
||||
|
||||
it "handles GibbonError" do
|
||||
mailchimp_bot = described_class.new(user)
|
||||
gibbon_error =
|
||||
Gibbon::GibbonError.new("You must set an api_key prior to making a call")
|
||||
allow(mailchimp_bot.gibbon).to receive(:upsert).and_raise(gibbon_error)
|
||||
|
||||
expect { mailchimp_bot.upsert_to_newsletter }.not_to raise_error
|
||||
end
|
||||
end
|
||||
|
||||
describe "manage community moderator list" do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue