This module is called every time an instance of a certain model is saved. It will check on some AccountMetrics and notify Account admins if a milestone is reached.
I'm testing with Minitest and the coverage report shows that the code never goes through notify_activecampaign_of_paid_invoices_milestone or get_account_admins, even though I'm checking with a byebug that it is actually called. It doesn't call the Crm::AddTagToContactJob either.
The whole module works as expected, but I can't test it 100% because I can't make it go through those two methods.
Any insight would be appreciated.
def call
notify_crm_of_1_transaction_milestone
notify_crm_of_10_transactions_milestone
notify_crm_of_50_transactions_milestone
notify_crm_of_100_transactions_milestone
end
def notify_crm_of_1_transaction_milestone
return unless account_metric_was.paid_invoices_count.zero? &&
account_metric.paid_invoices_count == 1
notify_activecampaign_of_paid_invoices_milestone("transactions_1") # this line is reached
end
def notify_activecampaign_of_paid_invoices_milestone(tag) # this method is never run, nor the Job called
users = get_account_admins(account_metric.account)
users.each do |user|
Crm::AddTagToContactJob.perform_later(user.id, tag)
end
end
def get_account_admins(account) # this method is never run
account.admins.where(permission_level: 3)
end
Aucun commentaire:
Enregistrer un commentaire