BathHacked/energy-sparks

View on GitHub
app/services/activation_email_sender.rb

Summary

Maintainability
A
25 mins
Test Coverage
class ActivationEmailSender
  def initialize(school)
    @school = school
  end

  def send
    unless @school.has_school_onboarding_event?(:activation_email_sent)
      users = @school.activation_users
      if users.any?
        OnboardingMailer.with_user_locales(users: users, school: @school) { |mailer| mailer.activation_email.deliver_now }

        onboarding_service.record_event(@school.school_onboarding, :activation_email_sent)
      end
    end
  end

  private

  def onboarding_service
    @onboarding_service ||= Onboarding::Service.new
  end
end