discourse/spec/mailers
Régis Hanol 5f6b6e9818 FIX: correctly compute the window for email summaries
In 958437e7dd we ensured that the email summaries are properly sent based on 'digest_attempted_at' for people who barely/never visit the forum.

This fixed the "frequency" of the email summaries but introduced a bug where the digest would be sent even though there wasn't anything new since for some users.

The logic we use to compute the threshold date for the content to be included in the digest was

```ruby
@since = opts[:since] || user.last_seen_at || user.user_stat&.digest_attempted_at || 1.month.ago
```

It was working as expected for users who haven never been seen but for users who have connected at least once, we would use their "last_seen_at" date as the "threshold date" for the content to be sent in a summary 😬

This fix changes the logic to be the most recent date amongst the `last_seen_at`, `digest_attempted_at` and `1.month.ago` so it's correctly handling cases where

- user has never been seen nor emailed a summary
- user has been seen in a while but has recently been sent a summary
- user has been sent a summary recently but hasn't been seen in a while.
2024-05-27 22:33:51 +02:00
..
group_smtp_mailer_spec.rb FIX: Add higher read & open timeouts for group SMTP emails (#24593) 2023-11-28 15:32:59 +10:00
invite_mailer_spec.rb DEV: Automatically update groups for test users with explicit TL (#25415) 2024-01-29 17:52:02 +08:00
rejection_mailer_spec.rb DEV: Update rubocop-discourse to latest version 2024-03-04 15:08:35 +01:00
subscription_mailer_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
test_mailer_spec.rb DEV: Apply syntax_tree formatting to `spec/*` 2023-01-09 11:49:28 +00:00
user_notifications_spec.rb FIX: correctly compute the window for email summaries 2024-05-27 22:33:51 +02:00
version_mailer_spec.rb DEV: Update the rubocop-discourse gem 2023-06-26 11:41:52 +02:00