mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
Move welcome emails placement
This commit is contained in:
parent
b9c1a5ccdb
commit
22daed7291
2 changed files with 10 additions and 1 deletions
|
|
@ -18,7 +18,7 @@ class User < ApplicationRecord # rubocop:disable Metrics/ClassLength
|
|||
after_create :create_api_key
|
||||
after_commit :activate, on: :create, if: -> { DawarichSettings.self_hosted? }
|
||||
after_commit :start_trial, on: :create, if: -> { !DawarichSettings.self_hosted? }
|
||||
after_commit :schedule_welcome_emails, on: :create, if: -> { !DawarichSettings.self_hosted? }
|
||||
|
||||
before_save :sanitize_input
|
||||
|
||||
validates :email, presence: true
|
||||
|
|
@ -140,6 +140,7 @@ class User < ApplicationRecord # rubocop:disable Metrics/ClassLength
|
|||
|
||||
def start_trial
|
||||
update(status: :trial, active_until: 7.days.from_now)
|
||||
schedule_welcome_emails
|
||||
|
||||
Users::TrialWebhookJob.perform_later(id)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -75,6 +75,14 @@ RSpec.describe User, type: :model do
|
|||
expect(Users::TrialWebhookJob).to receive(:perform_later).with(user.id)
|
||||
user.send(:start_trial)
|
||||
end
|
||||
|
||||
it 'schedules welcome emails' do
|
||||
allow(user).to receive(:schedule_welcome_emails)
|
||||
|
||||
user.send(:start_trial)
|
||||
|
||||
expect(user).to have_received(:schedule_welcome_emails)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#schedule_welcome_emails' do
|
||||
|
|
|
|||
Loading…
Reference in a new issue