diff --git a/config/initializers/airbrake.rb b/config/initializers/airbrake.rb index 889c82d..02f73b6 100644 --- a/config/initializers/airbrake.rb +++ b/config/initializers/airbrake.rb @@ -4,8 +4,15 @@ config.port = 443 config.secure = config.port == 443 + # this will be retried succesfully config.ignore_by_filter do |exception_data| exception_data["error_class"] == "AASM::InvalidTransition" && - exception_data["class"] == "DeliveryReceiptUpdateStatusJob" + (exception_data["parameters"] || {})["class"] == "DeliveryReceiptUpdateStatusJob" + end + + # this will be retried succesfully + config.ignore_by_filter do |exception_data| + exception_data["error_class"] == "PG::TRDeadlockDetected" && + (exception_data["parameters"] || {})["class"] == "ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper" end end diff --git a/spec/models/msisdn_discovery_spec.rb b/spec/models/msisdn_discovery_spec.rb index c3caa84..87d6ef2 100644 --- a/spec/models/msisdn_discovery_spec.rb +++ b/spec/models/msisdn_discovery_spec.rb @@ -99,11 +99,15 @@ describe "#notify" do let(:msisdn) { subject.msisdn } - before do + def setup_scenario reply subject.reload end + before do + setup_scenario + end + subject { create(:msisdn_discovery, state) } let(:reply) { create(:reply, reply_state, :msisdn_discovery => subject) } @@ -132,6 +136,15 @@ let(:state) { :awaiting_result } it { is_expected.to be_inactive } it { expect(msisdn).not_to be_active } + + context "this state is queued_for_discovery" do + let(:state) { :queued_for_discovery } + + def setup_scenario + end + + it { expect { reply }.to raise_error(AASM::InvalidTransition) } + end end context "expired" do