2019-07-30 21:29:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-02-11 22:10:57 +00:00
|
|
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe Campaign, type: :model do
|
|
|
|
describe 'sends correct email based on type of campaign' do
|
2019-07-30 21:29:24 +00:00
|
|
|
let(:nonprofit) { force_create(:nonprofit) }
|
2019-02-11 22:10:57 +00:00
|
|
|
let(:parent_campaign) { force_create(:campaign, name: 'Parent campaign', nonprofit: nonprofit) }
|
|
|
|
let(:child_campaign) do
|
|
|
|
force_create(:campaign,
|
|
|
|
name: 'Child campaign',
|
|
|
|
parent_campaign_id: parent_campaign.id,
|
2019-07-30 21:29:24 +00:00
|
|
|
slug: 'twehotiheiotheiofnieoth',
|
|
|
|
goal_amount_dollars: '1000', nonprofit: nonprofit)
|
2019-02-11 22:10:57 +00:00
|
|
|
end
|
|
|
|
|
2019-11-08 19:12:55 +00:00
|
|
|
it 'parent campaign sends out a create job' do
|
|
|
|
parent_campaign
|
|
|
|
expect(CampaignCreateJob).to have_been_enqueued.exactly(:once)
|
2019-02-11 22:10:57 +00:00
|
|
|
end
|
|
|
|
|
2019-11-08 19:12:55 +00:00
|
|
|
it 'child campaign sends out federated create job' do
|
|
|
|
parent_campaign
|
|
|
|
expect(CampaignCreateJob).to have_been_enqueued.exactly(:once)
|
|
|
|
child_campaign
|
|
|
|
expect(CampaignCreateJob).to have_been_enqueued.exactly(:twice)
|
2019-02-11 22:10:57 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|