From 3a3da903d84d50d327a34ff694867e1843b740fa Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Sun, 19 Jan 2025 21:06:49 +0530 Subject: [PATCH] feat: remove unnecessary tests --- app/jobs/process_resend_webhook_job.rb | 48 ------------------- spec/helpers/public/newsletter_helper_spec.rb | 15 ------ 2 files changed, 63 deletions(-) delete mode 100644 app/jobs/process_resend_webhook_job.rb delete mode 100644 spec/helpers/public/newsletter_helper_spec.rb diff --git a/app/jobs/process_resend_webhook_job.rb b/app/jobs/process_resend_webhook_job.rb deleted file mode 100644 index 9afdc76..0000000 --- a/app/jobs/process_resend_webhook_job.rb +++ /dev/null @@ -1,48 +0,0 @@ -class ProcessResendWebhookJob < ApplicationJob - queue_as :default - - def perform(payload) - @payload = payload.with_indifferent_access - @email = find_email_log - - event_name = @payload[:type].to_s.gsub(".", "_") - - if self.respond_to?("process_#{event_name}") - set_subscriber unless @email.subscriber_id.present? - send("process_#{event_name}") - end - end - - def process_email_delivered - @email.update(status: "delivered", delivered_at: @payload.dig(:created_at)) - end - - def process_email_complained - @email.update(status: "complained", complained_at: @payload.dig(:created_at)) - @email.subscriber.update(unsubscribed_at: @payload.dig(:data, :created_at), status: :unsubscribed, unsubscribe_reason: :complained) - end - - def process_email_bounced - @email.update(status: "bounced", bounced_at: @payload.dig(:created_at)) - # if bounced more than 3 times, unsubscribe the subscriber - bounce_count = Email.where(subscriber: @email.subscriber).bounced.count - @email.subscriber.update(unsubscribed_at: @payload.dig(:data, :created_at), status: :unsubscribed, unsubscribe_reason: :bounced) if bounce_count >= 3 - end - - private - - def set_subscriber - subscriber = find_subscriber - @email.update(subscriber: subscriber) - @email.reload - end - - def find_email_log - Email.find_by(email_id: @payload.dig(:data, :email_id)) - end - - def find_subscriber - to_emails = @payload.dig(:data, :to) - Subscriber.find_by(email: to_emails.first) - end -end diff --git a/spec/helpers/public/newsletter_helper_spec.rb b/spec/helpers/public/newsletter_helper_spec.rb deleted file mode 100644 index 91519fa..0000000 --- a/spec/helpers/public/newsletter_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the Public::NewsletterHelper. For example: -# -# describe Public::NewsletterHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe Public::NewsletterHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end