Skip to content

Instantly share code, notes, and snippets.

@abacha
Created April 14, 2026 14:29
Show Gist options
  • Select an option

  • Save abacha/6faacf2b334e176055ef1cfe25a89a0b to your computer and use it in GitHub Desktop.

Select an option

Save abacha/6faacf2b334e176055ef1cfe25a89a0b to your computer and use it in GitHub Desktop.
UAT Script: Hubstaff Extra Emails Suppression (HUB-14055)

How to trigger:

Part 1: Removed Emails (Should never send)

  1. AchievementMailer.earned_achievements
  • Trigger the achievement email for a user via rails console:
user = User.last
achievement = Achievement.last
AchievementMailer.earned_achievements(user.id, achievement.id).deliver_now
  • Expected result: The email should be suppressed and not sent.
  1. WorkSummaryMailer.me_work_summary & team_work_summary (daily)
  • Trigger the daily work summaries for a user and organization:
user = User.last
organization = user.organizations.last
date = Date.current.iso8601

WorkSummaryMailer.me_work_summary(user, organization, date, 'daily').deliver_now
WorkSummaryMailer.team_work_summary(user, organization, date, 'daily').deliver_now
  • Expected result: Neither email should be sent. (Sanity check: passing 'weekly' instead of 'daily' should still send the email).

Part 2: Suppressed Emails (Inactive > 30 days + Experiment ON)

  • First, setup the context in your rails console:
organization = Organization.last

# Setup User A (Active - tracked time recently)
active_user = User.find(...) # insert ID of an active user

# Setup User B (Inactive - no time tracked in > 30 days)
inactive_user = User.find(...) # insert ID of an inactive user
  1. AttendanceMailer.management_late_shift_notice
  • Trigger the late shift notice for both users:
active_shift = Shift.where(user: active_user).last
inactive_shift = Shift.where(user: inactive_user).last

AttendanceMailer.management_late_shift_notice(active_shift).deliver_now
AttendanceMailer.management_late_shift_notice(inactive_shift).deliver_now
  • Expected result: Only the email for active_user is sent.
  1. AttendanceMailer.management_missed_shift_notice
  • Trigger the missed shift notice:
active_shift = Shift.where(user: active_user).last
inactive_shift = Shift.where(user: inactive_user).last

AttendanceMailer.management_missed_shift_notice(active_shift).deliver_now
AttendanceMailer.management_missed_shift_notice(inactive_shift).deliver_now
  • Expected result: Only the email for active_user is sent.
  1. AttendanceMailer.management_abandoned_shift_notice
  • Trigger the abandoned shift notice:
active_shift = Shift.where(user: active_user).last
inactive_shift = Shift.where(user: inactive_user).last

AttendanceMailer.management_abandoned_shift_notice(active_shift).deliver_now
AttendanceMailer.management_abandoned_shift_notice(inactive_shift).deliver_now
  • Expected result: Only the email for active_user is sent.
  1. WorkBreakMailer.send_notice
  • Trigger the work break management notice:
active_break = WorkBreak.where(user: active_user).last
inactive_break = WorkBreak.where(user: inactive_user).last

WorkBreakMailer.send_notice(active_break).deliver_now
WorkBreakMailer.send_notice(inactive_break).deliver_now
  • Expected result: Only the email for active_user is sent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment