Fix ActiveUserCountThresholdWorker to actually send email
What does this MR do and why?
Fix ActiveUserCountThresholdWorker to actually send email
The worker was building the mailer, but not calling deliver_later, so the email was never actually sent. This adds the missing deliver_later call to ensure the license threshold notification is delivered.
Also updates the spec to use have_enqueued_mail matcher instead of stubbing mailer methods, providing better test coverage.
References
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
- Start your local GitLab instance with an Ultimate license and check if the worker really triggers an email by executing the following code:
license = License.current
license.define_singleton_method(:active_user_count_threshold_reached?) { true }
license.define_singleton_method(:remaining_user_count) { 1 }
ActionMailer::Base.deliveries.clear
ActionMailer::Base.delivery_method = :test
ActiveJob::Base.queue_adapter = :inline
ActiveUserCountThresholdWorker.new.perform
mail = ActionMailer::Base.deliveries.last
puts mail.subject # "Your subscription is nearing its user limit"
puts mail.bcc # Admin emailsMR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.