feat: add webhook_secret handling and validations for FlutterwaveProv… #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
User description
This pull request introduces several changes to enhance the functionality and testing of the
FlutterwaveProviderpayment provider. Key updates include improving secrets management, refining test cases, and adding comprehensive model validations.Enhancements to secrets management:
app/models/payment_providers/flutterwave_provider.rb: Addedwebhook_secrettosecrets_accessorsto centralize its management alongsidesecret_key.spec/factories/payment_providers.rb: Updated thesecretsandsettingsattributes in the factory to reflect the new secrets structure, ensuringwebhook_secretis properly handled.spec/services/payment_providers/flutterwave/handle_incoming_webhook_service_spec.rb: Adjusted the test setup to removewebhook_secretfrom thesecretsJSON structure instead ofsettings.Improvements to test coverage:
spec/models/payment_providers/flutterwave_provider_spec.rb: Added extensive tests for validations, constants, secrets accessors, webhook secret generation, and theFlutterwavePaymentdata structure to ensure robust functionality.Refinements in job queue testing:
spec/jobs/payment_providers/flutterwave/handle_event_job_spec.rb: Updated tests to usehave_enqueued_jobmatcher, improving readability and accuracy in verifying job queue assignments.PR Type
Enhancement
Description
• Moved
webhook_secretfrom settings to secrets for better security• Added comprehensive test coverage for FlutterwaveProvider model
• Fixed queue testing to use proper enqueue matchers
• Updated factory to reflect new secrets structure
Changes walkthrough 📝
flutterwave_provider.rb
Move webhook_secret to secrets accessorsapp/models/payment_providers/flutterwave_provider.rb
• Moved
webhook_secretfromsettings_accessorstosecrets_accessors•
Removed extra blank line for cleaner formatting
payment_providers.rb
Update factory for new secrets structurespec/factories/payment_providers.rb
• Added
webhook_secretto secrets JSON structure• Removed
webhook_secretfrom settings hash• Added transient
webhook_secretattribute
handle_event_job_spec.rb
Fix queue testing with proper matchersspec/jobs/payment_providers/flutterwave/handle_event_job_spec.rb
• Replaced
queue_nameassertions withhave_enqueued_job.on_queuematchers
• Added proper job enqueuing expectations for both queue
scenarios
flutterwave_provider_spec.rb
Add comprehensive FlutterwaveProvider model testsspec/models/payment_providers/flutterwave_provider_spec.rb
• Added comprehensive test suite for FlutterwaveProvider model
• Tests
validations, constants, webhook secret generation, and data structures
• Covers secrets accessors and payment type functionality
handle_incoming_webhook_service_spec.rb
Update webhook service test for secretsspec/services/payment_providers/flutterwave/handle_incoming_webhook_service_spec.rb
• Updated test to remove
webhook_secretfrom secrets JSON instead ofsettings
• Fixed webhook secret handling test for new secrets
structure