Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Iulian Masar committed Feb 8, 2024
1 parent aa402a4 commit 11c4103
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 49 deletions.
5 changes: 2 additions & 3 deletions spec/mangopay/deposit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
describe 'CREATE' do
it 'creates a new deposit' do
author = new_natural_user
card_registration = new_card_registration_completed_for_deposit
card_registration = new_card_registration_completed
deposit = create_new_deposit(card_registration['CardId'], author['Id'])

assert_deposit(deposit, card_registration['CardId'], author["Id"])
Expand All @@ -15,7 +15,7 @@
describe 'GET' do
it 'get an existing deposit' do
author = new_natural_user
card_registration = new_card_registration_completed_for_deposit
card_registration = new_card_registration_completed
deposit = create_new_deposit(card_registration['CardId'], author['Id'])

assert_deposit(deposit, card_registration['CardId'], author["Id"])
Expand Down Expand Up @@ -64,7 +64,6 @@ def assert_deposit(deposit, card_reg_id, author_id)
expect(deposit['CardId']).to eq(card_reg_id)
expect(deposit['AuthorId']).to eq(author_id)
expect(deposit['SecureModeReturnURL']).not_to be_nil
expect(deposit['SecureModeRedirectURL']).not_to be_nil
expect(deposit['PaymentType']).not_to be_nil
expect(deposit['ExecutionType']).not_to be_nil
expect(deposit['StatementDescriptor']).not_to be_nil
Expand Down
2 changes: 2 additions & 0 deletions spec/mangopay/payin_preauthorized_direct_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def check_type_and_status(payin)
describe 'CREATE' do
it 'creates a preauthorized direct payin' do
created = new_payin_preauthorized_direct
# wait for the transactions to be created
sleep(2)
transactions = MangoPay::PreAuthorization.transactions(created['PreauthorizationId'])
expect(created['Id']).not_to be_nil
expect(transactions[0]['Status']).to eq('SUCCEEDED')
Expand Down
2 changes: 1 addition & 1 deletion spec/mangopay/recurring_payin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

describe 'CREATE' do
it 'creates a recurring payment' do
cardreg = new_card_registration_3dsecure_completed
cardreg = new_card_registration_completed
wallet = new_wallet
recurring = MangoPay::PayIn::RecurringPayments::Recurring.create(
AuthorId: new_natural_user['Id'],
Expand Down
46 changes: 1 addition & 45 deletions spec/mangopay/shared_resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -379,51 +379,7 @@ def create_new_document(user)
data = {
data: cardreg['PreregistrationData'],
accessKeyRef: cardreg['AccessKey'],
cardNumber: 4970105191923460,
cardExpirationDate: 1226,
cardCvx: 123 }

res = Net::HTTP.post_form(URI(cardreg['CardRegistrationURL']), data)
raise Exception, [res, res.body] unless res.is_a?(Net::HTTPOK) && res.body.start_with?('data=')

cardreg['RegistrationData'] = res.body

# 3rd step: update (fills-in CardId) and return it
MangoPay::CardRegistration.update(cardreg['Id'],
RegistrationData: cardreg['RegistrationData'])
end

let(:new_card_registration_3dsecure_completed) do
# 1st step: create
cardreg = new_card_registration

# 2nd step: tokenize by payline (fills-in RegistrationData)
data = {
data: cardreg['PreregistrationData'],
accessKeyRef: cardreg['AccessKey'],
cardNumber: 4970105191923460,
cardExpirationDate: 1224,
cardCvx: 123 }

res = Net::HTTP.post_form(URI(cardreg['CardRegistrationURL']), data)
raise Exception, [res, res.body] unless res.is_a?(Net::HTTPOK) && res.body.start_with?('data=')

cardreg['RegistrationData'] = res.body

# 3rd step: update (fills-in CardId) and return it
MangoPay::CardRegistration.update(cardreg['Id'],
RegistrationData: cardreg['RegistrationData'])
end

let(:new_card_registration_completed_for_deposit) do
# 1st step: create
cardreg = new_card_registration

# 2nd step: tokenize by payline (fills-in RegistrationData)
data = {
data: cardreg['PreregistrationData'],
accessKeyRef: cardreg['AccessKey'],
cardNumber: 4970105181818183,
cardNumber: 4970107111111119,
cardExpirationDate: 1226,
cardCvx: 123 }

Expand Down
5 changes: 5 additions & 0 deletions spec/mangopay/transaction_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
it 'fetches list with two transactions after payin and payout done' do
payin = new_payin_card_direct
payout = create_new_payout_bankwire(payin)
# wait for the transactions to be created
sleep(2)
transactions = MangoPay::Transaction.fetch(new_wallet['Id'])

expect(transactions).to be_kind_of(Array)
Expand All @@ -37,6 +39,9 @@
payout = create_new_payout_bankwire(payin)
wallet_id = new_wallet['Id']

# wait for the transactions to be created
sleep(2)

by_nature_reg = MangoPay::Transaction.fetch(wallet_id, {'Nature' => 'REGULAR'})
by_nature_ref = MangoPay::Transaction.fetch(wallet_id, {'Nature' => 'REFUND'})
expect(by_nature_reg.count).to eq 2
Expand Down
2 changes: 2 additions & 0 deletions spec/mangopay/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
it 'fetches list with two transactions after payin and payout done' do
payin = new_payin_card_direct
payout = create_new_payout_bankwire(payin)
# wait for the transactions to be created
sleep(2)
transactions = MangoPay::User.transactions(new_natural_user['Id'])

expect(transactions).to be_kind_of(Array)
Expand Down
5 changes: 5 additions & 0 deletions spec/mangopay/wallet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
it 'fetches list with two transactions after payin and payout done' do
payin = new_payin_card_direct
payout = create_new_payout_bankwire(payin)
# wait for the transactions to be created
sleep(2)
transactions = MangoPay::Wallet.transactions(new_wallet['Id'])

expect(transactions).to be_kind_of(Array)
Expand All @@ -63,6 +65,9 @@
payout = create_new_payout_bankwire(payin)
wallet_id = new_wallet['Id']

# wait for the transactions to be created
sleep(2)

by_nature_reg = MangoPay::Wallet.transactions(wallet_id, {'Nature' => 'REGULAR'})
by_nature_ref = MangoPay::Wallet.transactions(wallet_id, {'Nature' => 'REFUND'})
expect(by_nature_reg.count).to eq 2
Expand Down

0 comments on commit 11c4103

Please sign in to comment.