Skip to content
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

🧠 🌴 Cleanup a bit braintree customer form data #3167

Merged
merged 4 commits into from
Jan 23, 2023

Conversation

josemigallas
Copy link
Contributor

No description provided.

@josemigallas josemigallas requested a review from a team January 19, 2023 14:26
@josemigallas josemigallas self-assigned this Jan 19, 2023
@josemigallas josemigallas changed the title cleanup a bit braintree customer form data 🧠 🌴 Cleanup a bit braintree customer form data Jan 19, 2023
lvillen
lvillen previously approved these changes Jan 19, 2023
Copy link
Contributor

@thalesmiguel thalesmiguel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple comments ✌️

app/helpers/payment_details_helper.rb Outdated Show resolved Hide resolved
app/helpers/payment_details_helper.rb Outdated Show resolved Hide resolved
app/helpers/payment_details_helper.rb Outdated Show resolved Hide resolved
app/helpers/payment_details_helper.rb Show resolved Hide resolved
Co-authored-by: Thales Miguel <thales.miguel@gmail.com>
…t so much more convenient

Co-authored-by: Thales Miguel <thales.miguel@gmail.com>
thalesmiguel
thalesmiguel previously approved these changes Jan 19, 2023
Copy link
Contributor

@thalesmiguel thalesmiguel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

named_route = [:admin, :account, merchant_account.payment_gateway_type]
polymorphic_path(named_route, url_params)
payment_gateway_type = merchant_account.payment_gateway_type
return '' if [:bogus, nil].include?(payment_gateway_type)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a test for this. It just looks a little risky what type is payment_gateway_type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added 11 years ago.. you seriously asking? LOL The whole thing is a bit of a mess so I wouldn't expect none of this is properly tested.
This were the "tests" that were implemented. At least there were a TODO 😂

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

precisely will be very useful to have an example when this bogus value may appear. I remember seeing that before and it is unnerving.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I think it's only enabled in development env, that's probably why the didn't bother testing it. Anyway, I don't think it is this PR's responsibility but I will take a good look into this and add some more tests.

akostadinov
akostadinov previously approved these changes Jan 19, 2023
Copy link
Contributor

@akostadinov akostadinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ruby part lgtm

Comment on lines -22 to -27
for (const key in billingAddress) {
// @ts-expect-error FIXME
if (billingAddress[key] === null) {
// @ts-expect-error FIXME
billingAddress[key] = ''
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been removed in favor of server side transform_values { |value| value.presence || '' }.

end

def edit_payment_details(merchant_account = site_account)
return "" if ["bogus" ,""].include?(merchant_account.payment_gateway_type.to_s)
polymorphic_url([:edit, :admin, :account, merchant_account.payment_gateway_type])
payment_gateway_type = merchant_account.payment_gateway_type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some further opportunities for refactoring:

  • rename edit_payment_details to edit_payment_details_path

And by the way, searching for this name (to check if there is any name clash) I stumbled on this helper: https://github.com/3scale/porta/blob/master/lib/developer_portal/lib/developer_portal/controller_methods/payment_paths_methods.rb#L11-L23

Which also implements another thing I was going to suggest: extracting [:bogus, nil].include?(payment_gateway_type) to a separate method, to avoid duplication of logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think #edit_payment_details is used anymore, I will remove it altogether. No need to refactor this.

Note: the method #unacceptable_payment_gateway? should be moved to Account::Gateway but I'm gonna refactor that in a following PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@josemigallas josemigallas merged commit ff27bb6 into master Jan 23, 2023
@josemigallas josemigallas deleted the cleanup_braintree_customer_form_data branch January 23, 2023 15:20
mayorova added a commit that referenced this pull request Jan 30, 2023
Upgrade Postgresql to version 13 in Dockerfile

allow easier caching of oracle gems

Now if one wants to cache only oracle gems when building
images so that gems are available in image but not installed
so only free bits are available in the image, then can do

```
BUNDLE_WITHOUT: "assets:test:development:default:preview:production"
bundle package
```

THREESCALE-8990: Add CMS API to the API Docs (#3136)

THREESCALE-8990: CMS access token scope: make  public (#3135)

* Clean up code from the CMS API rolling update
* Access Tokens: remove support for private APIs
* Access Token scopes: cleanup for private apis

Update thinking_sphinx.yml configuration file:

- add batch_size configuration (see below)
- remove the environments development, test, preview that are not needed in the container image
- group the different settings according to what they configure (thinking sphinx, searchd, etc.)

batch_size setting is required for reindexing in SaaS, as with the default value 1000 reindexing with `rake ts:rt:index` fails with the following error:
```
ThinkingSphinx::QueryLengthError: The supplied SphinxQL statement is 10266420 characters long. The maximum allowed length is 8388603.
```
Probably that's because of indexing CMS contents that can be quite long.

Fix link on Top Applications table (#3161)

prevents initial rerender by using ref instead of state

🧠 🌴 Cleanup a bit braintree customer form data (#3167)

* 🧠 🌴 extracts braintree customer form data from template
* ⚰️ removes unused method from PaymentDetailsHelper

Co-authored-by: Thales Miguel <thales.miguel@gmail.com>

♻️ dry: moves some logic to Account::Gateway module

fix pgsql and oracle tests

relying on record order is flaky

use common helper

🐛 removes duplicated flash message

CircleCI: Remove 3scale-ninjabot key (#3159)

♻️ extracts braintree form validation

CMS: Enforce params security for templates (#3152)

⚰️ removes unused methods from payment details helper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants