Skip to content

Commit

Permalink
DatapassWebhook::APIParticulier handles formulaire QF HubEE subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
skelz0r committed Jun 25, 2024
1 parent 3d3fec2 commit 78e5316
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class DatapassWebhook::ScheduleCreateFormulaireQFHubEESubscriptionJob < ApplicationInteractor
def call
return unless context.event == 'approve'
return unless context.modalities.include?('formulaire_qf')

CreateFormulaireQFHubEESubscriptionJob.perform_later(context.authorization_request.id)
end
end
1 change: 1 addition & 0 deletions app/organizers/datapass_webhook/api_particulier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class APIParticulier < ApplicationOrganizer
::DatapassWebhook::ReopenAuthorizationRequest,
::DatapassWebhook::RevokeCurrentToken,
::DatapassWebhook::UpdateMailjetContacts,
::DatapassWebhook::ScheduleCreateFormulaireQFHubEESubscriptionJob,
::DatapassWebhook::ExtractMailjetVariables,
::DatapassWebhook::ScheduleAuthorizationRequestEmails
end
Expand Down
44 changes: 44 additions & 0 deletions spec/organizers/datapass_webhook/v2/api_particulier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,50 @@
end
end

describe 'modalities' do
context 'when modalities does not include formulaire_qf' do
before do
datapass_webhook_params['data']['data']['modalities'] = ['params']
end

it 'does not schedule a job to create formulaire qf access on HubEE' do
expect {
subject
}.not_to have_enqueued_job(CreateFormulaireQFHubEESubscriptionJob)
end
end

context 'when modalities include formulaire_qf' do
before do
datapass_webhook_params['data']['data']['modalities'] = ['formulaire_qf']
end

context 'when event is approve' do
before do
datapass_webhook_params['event'] = 'approve'
end

it 'schedules a job to create formulaire qf access on HubEE' do
expect {
subject
}.to have_enqueued_job(CreateFormulaireQFHubEESubscriptionJob)
end
end

context 'when event not approve' do
before do
datapass_webhook_params['event'] = 'reject'
end

it 'does not schedule a job to create formulaire qf access on HubEE' do
expect {
subject
}.not_to have_enqueued_job(CreateFormulaireQFHubEESubscriptionJob)
end
end
end
end

describe 'Mailjet adding contacts' do
it 'adds contacts to Entreprise mailjet list' do
expect(Mailjet::Contactslist_managemanycontacts).to receive(:create).with(
Expand Down

0 comments on commit 78e5316

Please sign in to comment.