-
-
Notifications
You must be signed in to change notification settings - Fork 719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests app/services/stripe_payment_status.rb #11963
Tests app/services/stripe_payment_status.rb #11963
Conversation
This PR seems to interfere with other VCR tapes, I'll move this back to In Dev till this is clarified. |
36e5aba
to
265de61
Compare
@@ -162,6 +162,9 @@ | |||
vcr_config.default_cassette_options = { record: :none } if ENV["CI"] | |||
end | |||
example.run | |||
VCR.configure do |vcr_config| | |||
vcr_config.cassette_library_dir = "spec/fixtures/vcr_cassettes" | |||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems VCR was looking for a cassette in the Stripe folder, although this one is not related to Stripe:
VCR is currently using the following cassette:
- /home/runner/work/openfoodnetwork/openfoodnetwork/spec/fixtures/vcr_cassettes/Stripe-v10.3.0/ConnectAppJob/stores_connection_data_on_the_app.yml
Somehow, the around block on base spec helper is not really resetting the VCR configs. This change might just do it, but I'm not sure there isn't a better way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense: we are setting a different config value, and need to re-set it back after the example is completed. This would be relevant for the other config change too (default_cassette_options
).
I couldn't find a built-in method for achieving this, so would be tempted to build one..
For now, I'd suggest saving the current vcr_config before example.run
, then applying it again after.
I've pushed a new commit to demonstrate, let me know what you think.
I couldn't find a built-in way to do it, and couldn't even directly access the vcr config outside of VCR.configure. So this is the best way I could think of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, the spec updates look good.
I've added a suggested improvement, and have a comment about further simplifying the setup.
I think this is good as-is, but will await a second review for my code updates.
@@ -162,6 +162,9 @@ | |||
vcr_config.default_cassette_options = { record: :none } if ENV["CI"] | |||
end | |||
example.run | |||
VCR.configure do |vcr_config| | |||
vcr_config.cassette_library_dir = "spec/fixtures/vcr_cassettes" | |||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense: we are setting a different config value, and need to re-set it back after the example is completed. This would be relevant for the other config change too (default_cassette_options
).
I couldn't find a built-in method for achieving this, so would be tempted to build one..
For now, I'd suggest saving the current vcr_config before example.run
, then applying it again after.
I've pushed a new commit to demonstrate, let me know what you think.
preferred_enterprise_id: create(:enterprise).id) | ||
} | ||
|
||
before { Stripe.api_key = secret } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to suggest that we should reset the api key back after the end of the test. But then I realised that this key is the only key that would be used during tests, so we might as well set it once in envrionment config.
Then I realised we already do, in STRIPE_INSTANCE_SECRET_KEY
. Do you know why we set the test key in a special STRIPE_SECRET_TEST_API_KEY
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good team work.
What? Why?
Related to Epic #11890.
Closes #11962
Tests
app/services/stripe_payment_status.rb
by replacingreceive_message_chain
Rspec mocks with responses from VCR calls.What should we test?
Release notes
Changelog Category (reviewers may add a label for the release notes):
The title of the pull request will be included in the release notes.
Dependencies
Documentation updates