hackaru-app/hackaru-api

View on GitHub
app/mailers/report_mailer.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
# frozen_string_literal: true

class ReportMailer < ApplicationMailer
  def report(user, title, from, to)
    @title = title
    @report = build_report(user, from..to)
    @user_id = user.id
    mail(subject: @title, to: user.email)
  end

  private

  def build_report(user, range)
    report = Report.new(
      projects: user.projects,
      start_date: range.begin,
      end_date: range.end,
      time_zone: user.time_zone
    )
    report.valid!
    report
  end
end