All stats pass with listeners
This commit is contained in:
		
							parent
							
								
									2a20b9f381
								
							
						
					
					
						commit
						e1b2ac4d28
					
				
					 24 changed files with 70 additions and 69 deletions
				
			
		| 
						 | 
					@ -1,13 +0,0 @@
 | 
				
			||||||
class CampaignCreateJob < ApplicationJob
 | 
					 | 
				
			||||||
  queue_as :default
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  def perform(campaign)
 | 
					 | 
				
			||||||
    if campaign.child_campaign?
 | 
					 | 
				
			||||||
      CampaignCreationFederatedEmailJob.perform_later(campaign)
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
      CampaignCreationEmailFollowupJob.perform_later(campaign)
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    SupporterFundraiserCreateJob.perform_later(campaign)
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
							
								
								
									
										5
									
								
								app/listeners/application_listener.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								app/listeners/application_listener.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,5 @@
 | 
				
			||||||
 | 
					class ApplicationListener
 | 
				
			||||||
 | 
					  def name
 | 
				
			||||||
 | 
					    self.class.name
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
							
								
								
									
										11
									
								
								app/listeners/campaign_listener.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								app/listeners/campaign_listener.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,11 @@
 | 
				
			||||||
 | 
					class CampaignListener < ApplicationListener
 | 
				
			||||||
 | 
					    def campaign_create(campaign)
 | 
				
			||||||
 | 
					      if campaign.child_campaign?
 | 
				
			||||||
 | 
					        CampaignCreationFederatedEmailJob.perform_later(campaign)
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					        CampaignCreationEmailFollowupJob.perform_later(campaign)
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					      SupporterFundraiserCreateJob.perform_later(campaign)
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
class CreditCardPaymentListener
 | 
					class CreditCardPaymentListener < ApplicationListener
 | 
				
			||||||
    def donation_create(donation, locale, user=nil)
 | 
					    def donation_create(donation, locale, user=nil)
 | 
				
			||||||
      if donation.payment_provider == :credit_card
 | 
					      if donation.payment_provider == :credit_card
 | 
				
			||||||
        PaymentNotificationEmailDonorJob.perform_later donation, locale
 | 
					        PaymentNotificationEmailDonorJob.perform_later donation, locale
 | 
				
			||||||
| 
						 | 
					@ -16,5 +16,18 @@ class CreditCardPaymentListener
 | 
				
			||||||
    def refund_create(refund)
 | 
					    def refund_create(refund)
 | 
				
			||||||
      RefundNotificationJob.perform_later refund
 | 
					      RefundNotificationJob.perform_later refund
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
 | 
					    def recurring_donation_payment_succeeded(donation, locale, user=nil)
 | 
				
			||||||
 | 
					      if donation.payment_provider == :credit_card
 | 
				
			||||||
 | 
					        PaymentNotificationEmailDonorJob.perform_later donation, locale
 | 
				
			||||||
 | 
					        PaymentNotificationEmailNonprofitJob.perform_later donation, user
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def recurring_donation_payment_failed(donation, locale)
 | 
				
			||||||
 | 
					      FailedRecurringDonationPaymentDonorEmailJob.perform_later(donation)
 | 
				
			||||||
 | 
					      if (donation.recurring_donation.n_failures >= 3)
 | 
				
			||||||
 | 
					        FailedRecurringDonationPaymentNonprofitEmailJob.perform_later(donation)
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,4 @@
 | 
				
			||||||
class NonprofitMailerListener
 | 
					class NonprofitMailerListener < ApplicationListener
 | 
				
			||||||
 | 
					 | 
				
			||||||
    def nonprofit_create(nonprofit)
 | 
					    def nonprofit_create(nonprofit)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,12 +1,8 @@
 | 
				
			||||||
class SepaPaymentListener
 | 
					class SepaPaymentListener < ApplicationListener
 | 
				
			||||||
    def donation_create(donation)
 | 
					    def donation_create(donation)
 | 
				
			||||||
      if donation.payment_provider == :sepa
 | 
					      if donation.payment_provider == :sepa
 | 
				
			||||||
        DirectDebitCreateNotifyNonprofitJob.perform_later(donation.id)
 | 
					        DirectDebitCreateNotifyNonprofitJob.perform_later(donation.id)
 | 
				
			||||||
        DirectDebitCreateNotifyDonorJob.perform_later donation.id, locale
 | 
					        DirectDebitCreateNotifyDonorJob.perform_later donation.id, locale
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					 | 
				
			||||||
    def recurring_donation_create(donation, locale, user=nil)
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,2 +0,0 @@
 | 
				
			||||||
class SupporterMailerListener
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
class TicketListener
 | 
					class TicketListener < ApplicationListener
 | 
				
			||||||
    def ticket_create(tickets, charge, user=nil)
 | 
					    def ticket_create(tickets, charge, user=nil)
 | 
				
			||||||
        TicketMailer.followup(tickets.map{|i| i.id}, charge && charge.id).deliver_later
 | 
					        TicketMailer.followup(tickets.map{|i| i.id}, charge && charge.id).deliver_later
 | 
				
			||||||
        TicketMailer.receipt_admin(tickets.map{|i| i.id}, user && user.id).deliver_later
 | 
					        TicketMailer.receipt_admin(tickets.map{|i| i.id}, user && user.id).deliver_later
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
class WemoveListener
 | 
					class WemoveListener < ApplicationListener
 | 
				
			||||||
    def donation_create(donation)
 | 
					    def donation_create(donation)
 | 
				
			||||||
      WeMoveExecuteForDonationsJob.perform_later(donation)
 | 
					      WeMoveExecuteForDonationsJob.perform_later(donation)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -99,7 +99,7 @@ class Campaign < ApplicationRecord
 | 
				
			||||||
  after_create do
 | 
					  after_create do
 | 
				
			||||||
    user = profile.user
 | 
					    user = profile.user
 | 
				
			||||||
    Role.create(name: :campaign_editor, user_id: user.id, host: self)
 | 
					    Role.create(name: :campaign_editor, user_id: user.id, host: self)
 | 
				
			||||||
    CampaignCreateJob.perform_later(self)
 | 
					    HoudiniEventPublisher.announce(:campaign_create, self)
 | 
				
			||||||
    self
 | 
					    self
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,7 @@ development:
 | 
				
			||||||
  encoding: unicode
 | 
					  encoding: unicode
 | 
				
			||||||
  database: commitchange_development
 | 
					  database: commitchange_development
 | 
				
			||||||
  pool: 5
 | 
					  pool: 5
 | 
				
			||||||
  username: admin
 | 
					  username: houdini_user
 | 
				
			||||||
  password: password
 | 
					  password: password
 | 
				
			||||||
  host: <%= ENV['DATABASE_HOST']  || 'localhost' %>
 | 
					  host: <%= ENV['DATABASE_HOST']  || 'localhost' %>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,7 +27,7 @@ test:
 | 
				
			||||||
  encoding: unicode
 | 
					  encoding: unicode
 | 
				
			||||||
  database: commitchange_test
 | 
					  database: commitchange_test
 | 
				
			||||||
  pool: 5
 | 
					  pool: 5
 | 
				
			||||||
  username: admin
 | 
					  username: houdini_user
 | 
				
			||||||
  password: password
 | 
					  password: password
 | 
				
			||||||
  host: <%= ENV['DATABASE_HOST'] || 'localhost' %>
 | 
					  host: <%= ENV['DATABASE_HOST'] || 'localhost' %>
 | 
				
			||||||
ci:
 | 
					ci:
 | 
				
			||||||
| 
						 | 
					@ -35,7 +35,7 @@ ci:
 | 
				
			||||||
  encoding: unicode
 | 
					  encoding: unicode
 | 
				
			||||||
  database: commitchange_ci
 | 
					  database: commitchange_ci
 | 
				
			||||||
  pool: 5
 | 
					  pool: 5
 | 
				
			||||||
  username: admin
 | 
					  username: houdini_user
 | 
				
			||||||
  password: password
 | 
					  password: password
 | 
				
			||||||
  host: <%= ENV['DATABASE_HOST'] || 'localhost' %>
 | 
					  host: <%= ENV['DATABASE_HOST'] || 'localhost' %>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,7 +4,8 @@
 | 
				
			||||||
HoudiniEventPublisher = EventPublisher.new
 | 
					HoudiniEventPublisher = EventPublisher.new
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Rails.application.config.to_prepare do
 | 
					Rails.application.config.to_prepare do
 | 
				
			||||||
    HoudiniEventPublisher.clear if Rails.env.development?
 | 
					    Wisper.clear if Rails.env.development?
 | 
				
			||||||
 | 
					    [NonprofitMailerListener, CreditCardPaymentListener, SepaPaymentListener, TicketListener].each do |listener|
 | 
				
			||||||
    HoudiniEventPublisher.subscribe_async(NonprofitMailerListener.new)
 | 
					        HoudiniEventPublisher.subscribe_async(listener)
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,12 +13,6 @@ module CreateCampaign
 | 
				
			||||||
    if !params[:campaign][:parent_campaign_id]
 | 
					    if !params[:campaign][:parent_campaign_id]
 | 
				
			||||||
      campaign = nonprofit.campaigns.create params[:campaign]
 | 
					      campaign = nonprofit.campaigns.create params[:campaign]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      # do notifications
 | 
					 | 
				
			||||||
      user = campaign.profile.user
 | 
					 | 
				
			||||||
      Role.create(name: :campaign_editor, user_id: user.id, host: self)
 | 
					 | 
				
			||||||
      CampaignCreateJob.perform_later(self)
 | 
					 | 
				
			||||||
      SupporterFundraiserCreateJob.perform_later(self) unless QueryRoles.is_nonprofit_user?(user.id, nonprofit_id)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      return { errors: campaign.errors.messages }.as_json unless campaign.errors.empty?
 | 
					      return { errors: campaign.errors.messages }.as_json unless campaign.errors.empty?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      return campaign.as_json
 | 
					      return campaign.as_json
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,7 +4,7 @@
 | 
				
			||||||
class EventPublisher
 | 
					class EventPublisher
 | 
				
			||||||
    include Wisper::Publisher
 | 
					    include Wisper::Publisher
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def call(event, *args)
 | 
					    def announce(event, *args)
 | 
				
			||||||
        broadcast(event, *args)
 | 
					        broadcast(event, *args)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -43,7 +43,7 @@ module InsertDonation
 | 
				
			||||||
    result['donation'] = insert_donation(data, entities)
 | 
					    result['donation'] = insert_donation(data, entities)
 | 
				
			||||||
    update_donation_keys(result)
 | 
					    update_donation_keys(result)
 | 
				
			||||||
    result['activity'] = InsertActivities.for_one_time_donations([result['payment'].id])
 | 
					    result['activity'] = InsertActivities.for_one_time_donations([result['payment'].id])
 | 
				
			||||||
    HoudiniEventPublisher.call(:donation_create, result['donation'], result['donation'].supporter.locale)
 | 
					    HoudiniEventPublisher.announce(:donation_create, result['donation'], result['donation'].supporter.locale)
 | 
				
			||||||
    result
 | 
					    result
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -104,7 +104,7 @@ module InsertDonation
 | 
				
			||||||
    result['donation'] = insert_donation(data, entities)
 | 
					    result['donation'] = insert_donation(data, entities)
 | 
				
			||||||
    update_donation_keys(result)
 | 
					    update_donation_keys(result)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    HoudiniEventPublisher.call(:donation_create, result['donation'], locale_for_supporter(result['donation'].supporter.id))
 | 
					    HoudiniEventPublisher.announce(:donation_create, result['donation'], locale_for_supporter(result['donation'].supporter.id))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # do this for making test consistent
 | 
					    # do this for making test consistent
 | 
				
			||||||
    result['activity'] = {}
 | 
					    result['activity'] = {}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -70,7 +70,7 @@ module InsertRecurringDonation
 | 
				
			||||||
      result['activity'] = InsertActivities.for_recurring_donations([result['payment'].id])
 | 
					      result['activity'] = InsertActivities.for_recurring_donations([result['payment'].id])
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    # Send receipts
 | 
					    # Send receipts
 | 
				
			||||||
    HoudiniEventPublisher.call(:recurring_donation_create, result['donation'], entities[:supporter_id].locale)
 | 
					    HoudiniEventPublisher.announce(:recurring_donation_create, result['donation'], entities[:supporter_id].locale)
 | 
				
			||||||
    result
 | 
					    result
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -93,7 +93,7 @@ module InsertRecurringDonation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    InsertDonation.update_donation_keys(result) if result['payment']
 | 
					    InsertDonation.update_donation_keys(result) if result['payment']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    HoudiniEventPublisher.call(:recurring_donation_create, result['donation'], entities[:supporter_id].locale)
 | 
					    HoudiniEventPublisher.announce(:recurring_donation_create, result['donation'], entities[:supporter_id].locale)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    { status: 200, json: result }
 | 
					    { status: 200, json: result }
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -66,7 +66,7 @@ module InsertRefunds
 | 
				
			||||||
    # Update original payment to increment its refund_total for any future refund attempts
 | 
					    # Update original payment to increment its refund_total for any future refund attempts
 | 
				
			||||||
    Qx.update(:payments).set("refund_total=refund_total + #{h['amount'].to_i}").ts.where(id: original_payment['id']).execute
 | 
					    Qx.update(:payments).set("refund_total=refund_total + #{h['amount'].to_i}").ts.where(id: original_payment['id']).execute
 | 
				
			||||||
    # Send the refund receipts in a delayed job
 | 
					    # Send the refund receipts in a delayed job
 | 
				
			||||||
    HoudiniEventPublisher.call(:create_refund, Refund.find(refund_row['id']))
 | 
					    HoudiniEventPublisher.announce(:create_refund, Refund.find(refund_row['id']))
 | 
				
			||||||
    { 'payment' => payment_row, 'refund' => refund_row }
 | 
					    { 'payment' => payment_row, 'refund' => refund_row }
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -100,7 +100,7 @@ module InsertTickets
 | 
				
			||||||
    ticket_ids = result['tickets'].map(&:id)
 | 
					    ticket_ids = result['tickets'].map(&:id)
 | 
				
			||||||
    charge_id =  result['charge'] ? result['charge'].id : nil
 | 
					    charge_id =  result['charge'] ? result['charge'].id : nil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    HoudiniEventPublisher.call(:ticket_create, result['tickets'], result['charge'])
 | 
					    HoudiniEventPublisher.announce(:ticket_create, result['tickets'], result['charge'])
 | 
				
			||||||
    result
 | 
					    result
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -75,21 +75,16 @@ module PayRecurringDonation
 | 
				
			||||||
                            'old_donation' => true
 | 
					                            'old_donation' => true
 | 
				
			||||||
                          ))
 | 
					                          ))
 | 
				
			||||||
    if result['charge']['status'] != 'failed'
 | 
					    if result['charge']['status'] != 'failed'
 | 
				
			||||||
      result['recurring_donation'] = Psql.execute(
 | 
					      rd.update_attributes(n_failures: 0)
 | 
				
			||||||
        Qexpr.new.update(:recurring_donations, n_failures: 0)
 | 
					      result['recurring_donation'] =  rd
 | 
				
			||||||
          .where('id=$id', id: rd_id).returning('*')
 | 
					      HoudiniEventPublisher.announce(:recurring_donation_payment_succeeded, donation, donation&.supporter&.locale || 'en')
 | 
				
			||||||
      ).first
 | 
					 | 
				
			||||||
      PaymentNotificationJob.perform_later donation, donation&.supporter&.locale || 'en'
 | 
					 | 
				
			||||||
      InsertActivities.for_recurring_donations([result['payment']['id']])
 | 
					      InsertActivities.for_recurring_donations([result['payment']['id']])
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
      result['recurring_donation'] = Psql.execute(
 | 
					      
 | 
				
			||||||
        Qexpr.new.update(:recurring_donations, n_failures: rd['n_failures'] + 1)
 | 
					      rd.n_failures += 1
 | 
				
			||||||
          .where('id=$id', id: rd_id).returning('*')
 | 
					      rd.save!
 | 
				
			||||||
      ).first
 | 
					      result['recurring_donation'] = rd
 | 
				
			||||||
     FailedRecurringDonationPaymentDonorEmailJob.perform_later Donation.find(rd['donation_id'])
 | 
					      HoudiniEventPublisher.announce(:recurring_donation_payment_failed, donation)
 | 
				
			||||||
      if rd['n_failures'] >= 3
 | 
					 | 
				
			||||||
        FailedRecurringDonationPaymentNonprofitEmailJob.perform_later Donation.find(rd['donation_id'])
 | 
					 | 
				
			||||||
      end
 | 
					 | 
				
			||||||
      InsertSupporterNotes.create([{ content: "This supporter had a payment failure for their recurring donation with ID #{rd_id}", supporter_id: donation['supporter_id'], user_id: 540 }])
 | 
					      InsertSupporterNotes.create([{ content: "This supporter had a payment failure for their recurring donation with ID #{rd_id}", supporter_id: donation['supporter_id'], user_id: 540 }])
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    result
 | 
					    result
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -98,6 +98,7 @@ describe InsertDonation do
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      it 'process campaign donation' do
 | 
					      it 'process campaign donation' do
 | 
				
			||||||
 | 
					        expect(HoudiniEventPublisher).to receive(:announce).with(:campaign_create, any_args)
 | 
				
			||||||
        process_campaign_donation { InsertDonation.with_stripe(amount: charge_amount, nonprofit_id: nonprofit.id, supporter_id: supporter.id, token: source_token.token, campaign_id: campaign.id, date: (Time.now + 1.day).to_s, dedication: 'dedication', designation: 'designation') }
 | 
					        process_campaign_donation { InsertDonation.with_stripe(amount: charge_amount, nonprofit_id: nonprofit.id, supporter_id: supporter.id, token: source_token.token, campaign_id: campaign.id, date: (Time.now + 1.day).to_s, dedication: 'dedication', designation: 'designation') }
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -131,6 +132,7 @@ describe InsertDonation do
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      it 'process campaign donation' do
 | 
					      it 'process campaign donation' do
 | 
				
			||||||
 | 
					        expect(HoudiniEventPublisher).to receive(:announce).with(:campaign_create, any_args)
 | 
				
			||||||
        process_campaign_donation(sepa: true) { InsertDonation.with_sepa(amount: charge_amount, nonprofit_id: nonprofit.id, supporter_id: supporter.id, direct_debit_detail_id: direct_debit_detail.id, campaign_id: campaign.id, date: (Time.now + 1.day).to_s, dedication: 'dedication', designation: 'designation') }
 | 
					        process_campaign_donation(sepa: true) { InsertDonation.with_sepa(amount: charge_amount, nonprofit_id: nonprofit.id, supporter_id: supporter.id, direct_debit_detail_id: direct_debit_detail.id, campaign_id: campaign.id, date: (Time.now + 1.day).to_s, dedication: 'dedication', designation: 'designation') }
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -131,6 +131,7 @@ describe InsertRecurringDonation do
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        it 'process campaign donation' do
 | 
					        it 'process campaign donation' do
 | 
				
			||||||
 | 
					          expect(HoudiniEventPublisher).to receive(:announce).with(:campaign_create, any_args)
 | 
				
			||||||
          process_campaign_donation(recurring_donation: { paydate: nil, interval: 2, time_unit: 'month', start_date: Time.current.beginning_of_day }) { InsertRecurringDonation.with_stripe(amount: charge_amount, nonprofit_id: nonprofit.id, supporter_id: supporter.id, token: source_token.token, campaign_id: campaign.id, date: (Time.now + 1.day).to_s, dedication: 'dedication', designation: 'designation', recurring_donation: { interval: 2 }) }
 | 
					          process_campaign_donation(recurring_donation: { paydate: nil, interval: 2, time_unit: 'month', start_date: Time.current.beginning_of_day }) { InsertRecurringDonation.with_stripe(amount: charge_amount, nonprofit_id: nonprofit.id, supporter_id: supporter.id, token: source_token.token, campaign_id: campaign.id, date: (Time.now + 1.day).to_s, dedication: 'dedication', designation: 'designation', recurring_donation: { interval: 2 }) }
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -285,7 +285,7 @@ describe InsertTickets do
 | 
				
			||||||
          success_expectations
 | 
					          success_expectations
 | 
				
			||||||
          expect(QueryRoles).to receive(:is_authorized_for_nonprofit?).with(user.id, nonprofit.id).and_return true
 | 
					          expect(QueryRoles).to receive(:is_authorized_for_nonprofit?).with(user.id, nonprofit.id).and_return true
 | 
				
			||||||
          result = nil
 | 
					          result = nil
 | 
				
			||||||
          expect(HoudiniEventPublisher).to receive(:call).with(:ticket_create, any_args)
 | 
					          expect(HoudiniEventPublisher).to receive(:announce).with(:ticket_create, any_args)
 | 
				
			||||||
          result = InsertTickets.create(tickets: [{ quantity: 1, ticket_level_id: ticket_level.id }], nonprofit_id: nonprofit.id, supporter_id: supporter.id, token: source_token.token, event_id: event.id, kind: 'offsite', offsite_payment: { kind: 'check', check_number: 'fake_checknumber' }, current_user: user)
 | 
					          result = InsertTickets.create(tickets: [{ quantity: 1, ticket_level_id: ticket_level.id }], nonprofit_id: nonprofit.id, supporter_id: supporter.id, token: source_token.token, event_id: event.id, kind: 'offsite', offsite_payment: { kind: 'check', check_number: 'fake_checknumber' }, current_user: user)
 | 
				
			||||||
          
 | 
					          
 | 
				
			||||||
          expected = generate_expected_tickets(payment_id: result['payment'].id,
 | 
					          expected = generate_expected_tickets(payment_id: result['payment'].id,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,15 +16,14 @@ RSpec.describe Campaign, type: :model do
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it 'parent campaign sends out a create job' do
 | 
					    it 'parent campaign sends out a create job' do
 | 
				
			||||||
 | 
					      expect(HoudiniEventPublisher).to receive(:announce).with(:campaign_create, any_args).exactly(:once)
 | 
				
			||||||
      parent_campaign
 | 
					      parent_campaign
 | 
				
			||||||
      expect(CampaignCreateJob).to have_been_enqueued.exactly(:once)
 | 
					 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it 'child campaign sends out federated create job' do
 | 
					    it 'child campaign sends out federated create job' do
 | 
				
			||||||
 | 
					       expect(HoudiniEventPublisher).to receive(:announce).with(:campaign_create, any_args).exactly(:twice)
 | 
				
			||||||
      parent_campaign
 | 
					      parent_campaign
 | 
				
			||||||
      expect(CampaignCreateJob).to have_been_enqueued.exactly(:once)
 | 
					 | 
				
			||||||
      child_campaign
 | 
					      child_campaign
 | 
				
			||||||
      expect(CampaignCreateJob).to have_been_enqueued.exactly(:twice)
 | 
					 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -376,9 +376,9 @@ RSpec.shared_context :shared_rd_donation_value_context do
 | 
				
			||||||
    pay_method = data[:sepa] ? direct_debit_detail : card
 | 
					    pay_method = data[:sepa] ? direct_debit_detail : card
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    unless (data[:recurring_donation])
 | 
					    unless (data[:recurring_donation])
 | 
				
			||||||
      expect(HoudiniEventPublisher).to receive(:call).with(:donation_create,instance_of(Donation), supporter.locale )
 | 
					      expect(HoudiniEventPublisher).to receive(:announce).with(:donation_create,instance_of(Donation), supporter.locale )
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
      expect(HoudiniEventPublisher).to receive(:call).with(:recurring_donation_create,instance_of(Donation), supporter.locale )
 | 
					      expect(HoudiniEventPublisher).to receive(:announce).with(:recurring_donation_create,instance_of(Donation), supporter.locale )
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    result = yield
 | 
					    result = yield
 | 
				
			||||||
    expected = generate_expected(@donation_id, result['payment'].id, result['charge'].id, pay_method, supporter, nonprofit, @stripe_charge_id, event: event, recurring_donation_expected: data[:recurring_donation], recurring_donation: result['recurring_donation'])
 | 
					    expected = generate_expected(@donation_id, result['payment'].id, result['charge'].id, pay_method, supporter, nonprofit, @stripe_charge_id, event: event, recurring_donation_expected: data[:recurring_donation], recurring_donation: result['recurring_donation'])
 | 
				
			||||||
| 
						 | 
					@ -399,9 +399,9 @@ RSpec.shared_context :shared_rd_donation_value_context do
 | 
				
			||||||
    pay_method = data[:sepa] ? direct_debit_detail : card
 | 
					    pay_method = data[:sepa] ? direct_debit_detail : card
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    unless (data[:recurring_donation])
 | 
					    unless (data[:recurring_donation])
 | 
				
			||||||
      expect(HoudiniEventPublisher).to receive(:call).with(:donation_create,instance_of(Donation), supporter.locale )
 | 
					      expect(HoudiniEventPublisher).to receive(:announce).with(:donation_create,instance_of(Donation), supporter.locale )
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
      expect(HoudiniEventPublisher).to receive(:call).with(:recurring_donation_create,instance_of(Donation), supporter.locale )
 | 
					      expect(HoudiniEventPublisher).to receive(:announce).with(:recurring_donation_create,instance_of(Donation), supporter.locale )
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    result = yield
 | 
					    result = yield
 | 
				
			||||||
    expected = generate_expected(@donation_id, result['payment'].id, result['charge'].id, pay_method, supporter, nonprofit, @stripe_charge_id, campaign: campaign, recurring_donation_expected: data[:recurring_donation], recurring_donation: result['recurring_donation'])
 | 
					    expected = generate_expected(@donation_id, result['payment'].id, result['charge'].id, pay_method, supporter, nonprofit, @stripe_charge_id, campaign: campaign, recurring_donation_expected: data[:recurring_donation], recurring_donation: result['recurring_donation'])
 | 
				
			||||||
| 
						 | 
					@ -420,9 +420,9 @@ RSpec.shared_context :shared_rd_donation_value_context do
 | 
				
			||||||
  def process_general_donation(data = {})
 | 
					  def process_general_donation(data = {})
 | 
				
			||||||
    pay_method = data[:sepa] ? direct_debit_detail : card
 | 
					    pay_method = data[:sepa] ? direct_debit_detail : card
 | 
				
			||||||
    unless (data[:recurring_donation])
 | 
					    unless (data[:recurring_donation])
 | 
				
			||||||
      expect(HoudiniEventPublisher).to receive(:call).with(:donation_create,instance_of(Donation), supporter.locale )
 | 
					      expect(HoudiniEventPublisher).to receive(:announce).with(:donation_create,instance_of(Donation), supporter.locale )
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
      expect(HoudiniEventPublisher).to receive(:call).with(:recurring_donation_create,instance_of(Donation), supporter.locale )
 | 
					      expect(HoudiniEventPublisher).to receive(:announce).with(:recurring_donation_create,instance_of(Donation), supporter.locale )
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    result = yield
 | 
					    result = yield
 | 
				
			||||||
    expect_payment = nil_or_true(data[:expect_payment])
 | 
					    expect_payment = nil_or_true(data[:expect_payment])
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue