chore: Add validations to campaign model

- Add validations to campaign model ensuring that the associated inbox belongs to one with in the campaign account.
This commit is contained in:
Shivam Mishra
2025-03-20 05:59:08 +05:30
committed by GitHub
parent cc8c05834a
commit 51ad80a61e
7 changed files with 60 additions and 24 deletions

View File

@@ -2,12 +2,14 @@ require 'rails_helper'
RSpec.describe Campaigns::TriggerOneoffCampaignJob do
let(:account) { create(:account) }
let!(:twilio_sms) { create(:channel_twilio_sms) }
let!(:twilio_inbox) { create(:inbox, channel: twilio_sms) }
let!(:twilio_sms) { create(:channel_twilio_sms, account: account) }
let!(:twilio_inbox) { create(:inbox, channel: twilio_sms, account: account) }
let(:label1) { create(:label, account: account) }
let(:label2) { create(:label, account: account) }
let!(:campaign) { create(:campaign, inbox: twilio_inbox, audience: [{ type: 'Label', id: label1.id }, { type: 'Label', id: label2.id }]) }
let!(:campaign) do
create(:campaign, inbox: twilio_inbox, account: account, audience: [{ type: 'Label', id: label1.id }, { type: 'Label', id: label2.id }])
end
it 'enqueues the job' do
expect { described_class.perform_later(campaign) }.to have_enqueued_job(described_class)