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

[Mercadopago] authorization tests #142

Closed
wants to merge 4 commits into from
Closed

Conversation

subpal
Copy link
Contributor

@subpal subpal commented Mar 31, 2018

No description provided.

@subpal subpal changed the title Mercadopago_auth_test [Mercadopago] authorization tests Mar 31, 2018
@@ -2,35 +2,136 @@ defmodule Gringotts.Integration.Gateways.MercadopagoTest do
# Integration tests for the Mercadopago

use ExUnit.Case, async: false
Copy link
Contributor

Choose a reason for hiding this comment

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

Please run tests asynchronously.


describe "environment setup" do
test "old customer with bad_opts and bad_opts" do
Copy link
Contributor

Choose a reason for hiding this comment

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

typo in title 😁

public_key: "TEST-911f45a1-0560-4c16-915e-a8833830b29a"],
installments: 1
]
@new_cutomer_bad_opts [order_id: 123126,
Copy link
Contributor

Choose a reason for hiding this comment

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

The only difference between @new_cutomer_good_opts and @new_cutomer_bad_opts is in the :config key. Please do not test the presence or absence of required_fields in your opts because the tests for that have been written in gringotts_test.exs

@good_opts [email: "[email protected]",
order_id: 123126,
customer_id: "311211654-YrXF6J0QikpIWX",
config: [access_token: "TEST-2774702803649645-031303-1b9d3d63acb57cdad3458d386eee62bd-307592510",
Copy link
Contributor

Choose a reason for hiding this comment

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

You can move the :config key out and make it a module attribute.

end

describe "refund" do
end
describe "[authorize]" do
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you break this describe block into two, authorize new customer and authorize old customer?
I'm sure you'll be able to use new_email_opts/1 as a setup function (docs).

@codecov-io
Copy link

codecov-io commented Apr 17, 2018

Codecov Report

Merging #142 into mercadopago will decrease coverage by 7.42%.
The diff coverage is 0%.

Impacted file tree graph

@@               Coverage Diff               @@
##           mercadopago     #142      +/-   ##
===============================================
- Coverage        57.62%   50.19%   -7.43%     
===============================================
  Files               15       15              
  Lines              472      504      +32     
===============================================
- Hits               272      253      -19     
- Misses             200      251      +51
Impacted Files Coverage Δ
lib/gringotts/gateways/mercadopago.ex 0% <0%> (ø) ⬆️
lib/gringotts/gateways/paymill.ex 0% <0%> (-100%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b8692ba...3a9fcc2. Read the comment docs.

@subpal subpal force-pushed the mercado_auth_test branch from 85bf31f to 8980821 Compare April 18, 2018 17:52
@@ -1,15 +1,13 @@
defmodule Gringotts.Gateways.<%= gateway_module <> "Test" %> do
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this file from this PR.

defmodule Gringotts.Integration.Gateways.MercadopagoTest do
# Integration tests for the Mercadopago

use ExUnit.Case, async: false
Copy link
Contributor

Choose a reason for hiding this comment

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

async true pls! We ❤️ fast tests.


test "new cutomer with good_opts and good_card" do
use_cassette "mercadopago/authorize_new cutomer with good_opts and good_card" do
opts = new_email_opts(true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please read up on how to use a setup function in tests. This test and the one below it can be clubbed in a describe block with a common setup function that generates "new email opts".

@@ -0,0 +1,7 @@
defmodule Gringotts.Gateways.MercadopagoMock do
Copy link
Contributor

Choose a reason for hiding this comment

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

You can remove this file as well.

subpal and others added 2 commits April 22, 2018 19:45
https://www.mercadopago.com/

* Implements `authorize/3`.
* `@moduledoc` and docs added

authorize
---------

* Following optional arguments implemented:
  - `email`, `order_id`, `customer_id`, `order_type`, `installments`
* Mercadopago provides an `access_token` and ` `public_key` for auth.
* Mercadopago payments don't have any (writable) currency field, it
seems that currency of the transaction is set by Mercadopago
automatically from the merchant account.
@mandarvaze
Copy link
Collaborator

Superceded by #185

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants