diff --git a/app/controllers/api/datapass_webhooks_v2_controller.rb b/app/controllers/api/datapass_webhooks_v2_controller.rb index 4cba8bf01..4388493ee 100644 --- a/app/controllers/api/datapass_webhooks_v2_controller.rb +++ b/app/controllers/api/datapass_webhooks_v2_controller.rb @@ -9,7 +9,6 @@ def datapass_webhook_params :model_type, :model_id, :fired_at, - :public_id, data: {} ).to_h.symbolize_keys end diff --git a/app/interactors/datapass_webhook/adapt_v2_to_v1.rb b/app/interactors/datapass_webhook/adapt_v2_to_v1.rb index 8daf74985..7a4dc7f91 100644 --- a/app/interactors/datapass_webhook/adapt_v2_to_v1.rb +++ b/app/interactors/datapass_webhook/adapt_v2_to_v1.rb @@ -11,7 +11,7 @@ def build_data { 'pass' => { 'id' => context.model_id, - 'public_id' => context.public_id, + 'public_id' => context.data['public_id'], 'intitule' => generic_data['intitule'], 'description' => generic_data['description'], 'demarche' => context.data['form_uid'], diff --git a/spec/controllers/api/datapass_webhooks_v2_controller_spec.rb b/spec/controllers/api/datapass_webhooks_v2_controller_spec.rb index d5a23575e..1f3d47c50 100644 --- a/spec/controllers/api/datapass_webhooks_v2_controller_spec.rb +++ b/spec/controllers/api/datapass_webhooks_v2_controller_spec.rb @@ -6,7 +6,6 @@ 'event' => event, 'model_id' => 9001, 'model_type' => 'Pass', - 'public_id' => public_id, 'fired_at' => Time.now.to_i.to_s, 'data' => { 'what' => 'ever' @@ -14,8 +13,6 @@ } end - let(:public_id) { SecureRandom.uuid } - describe '#api_entreprise' do subject do post :api_entreprise, params: @@ -59,15 +56,8 @@ ) end - it 'calls DatapassWebhook::V2::APIEntreprise with public id and data)' do - expect(DatapassWebhook::V2::APIEntreprise).to receive(:call).with( - hash_including( - public_id:, - data: { - 'what' => 'ever' - } - ) - ) + it 'calls DatapassWebhook::V2::APIEntreprise' do + expect(DatapassWebhook::V2::APIEntreprise).to receive(:call) subject end diff --git a/spec/factories/datapass_webhooks_v2.rb b/spec/factories/datapass_webhooks_v2.rb index c60434f91..323b5dddd 100644 --- a/spec/factories/datapass_webhooks_v2.rb +++ b/spec/factories/datapass_webhooks_v2.rb @@ -6,7 +6,6 @@ initialize_with { attributes.stringify_keys } event { %w[refuse_application refuse].sample } - public_id { generate(:datapass_webhook_v2_public_id) } model_id { generate(:datapass_webhook_v2_id) } model_type { 'authorization_request/api_entreprise' } fired_at { Time.zone.now.to_i } @@ -17,6 +16,7 @@ initialize_with { attributes.stringify_keys } state { %w[approved refused].sample } + public_id { generate(:datapass_webhook_v2_public_id) } form_uid { 'api-entreprise' } applicant factory: :datapass_webhook_applicant_v2 organization factory: :datapass_webhook_organization_v2