Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Ruby Gems
/
var
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Ricardo Garcia
2016-07-11 15:43:07 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9a6022c6b320a14fdd1bfa653ffc577dd0311b14
9a6022c6
1 parent
3dd858e4
Builds for 1 pipeline
failed
in 0 seconds
Move webhook params
Changes
4
Builds
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
4 deletions
.rubocop.yml
spec/mocks/webhooks_requests.rb
spec/spec_helper.rb
spec/var_spec.rb
.rubocop.yml
View file @
9a6022c
AllCops
:
TargetRubyVersion
:
2.3
Exclude
:
-
'
spec/mock/webhooks_requests.rb'
...
...
spec/mocks/webhooks_requests.rb
View file @
9a6022c
module
WebHookPostRequest
CARD_CHARGE_CREATED
=
{
"data"
:
{
"object"
:
{
"id"
:
'5511d4ce2412294cf6000081'
,
"livemode"
:
false
,
"created_at"
:
1_427_231_950
,
"status"
:
'pending_payment'
,
"currency"
:
'MXN'
,
"description"
:
'Stogies'
,
"reference_id"
:
'9839-wolf_pack'
,
"failure_code"
:
nil
,
"failure_message"
:
nil
,
"monthly_installments"
:
nil
,
"object"
:
'charge'
,
"amount"
:
20_000
,
"paid_at"
:
nil
,
"fee"
:
963
,
"customer_id"
:
''
,
"refunds"
:
[],
"payment_method"
:
{
"name"
:
'Jorge Lopez'
,
"exp_month"
:
'12'
,
"exp_year"
:
'19'
,
"auth_code"
:
nil
,
"object"
:
'card_payment'
,
"last4"
:
'4242'
,
"brand"
:
'visa'
},
"details"
:
{
"name"
:
nil
,
"phone"
:
nil
,
"email"
:
nil
,
"line_items"
:
[]
}
},
"previous_attributes"
:
{}
},
"livemode"
:
false
,
"webhook_status"
:
'pending'
,
"id"
:
'5511d4ce2412294cf6000084'
,
"object"
:
'event'
,
"type"
:
'charge.created'
,
"created_at"
:
1_427_231_950
,
"webhook_logs"
:
[{
"id"
:
'webhl_nPzGMBeQmMUu7aQ'
,
"url"
:
'http://requestb.in/1em0jsx1'
,
"failed_attempts"
:
0
,
"last_http_response_status"
:
-
1
,
"object"
:
'webhook_log'
,
"last_attempted_at"
:
0
}]
}
OXXO_CHARGE_CREATED
=
{
"data"
:
{
"object"
:
{
"id"
:"5514803f241229981e0022e6"
,
"livemode"
:false
,
"created_at"
:
1427406911
,
"status"
:"pending_payment"
,
"currency"
:"MXN"
,
"description"
:"Stogies"
,
"reference_id"
:"9839-wolf_pack"
,
"failure_code"
:n
ull
,
"failure_message"
:null
,
"monthly_installments"
:nul
l
,
"object"
:"charge"
,
"amount"
:
20000
,
"paid_at"
:n
ul
l
,
"fee"
:
812
,
"failure_code"
:n
il
,
"failure_message"
:nil
,
"monthly_installments"
:ni
l
,
"object"
:"charge"
,
"amount"
:
20000
,
"paid_at"
:n
i
l
,
"fee"
:
812
,
"customer_id"
:""
,
"refunds"
:[]
,
"payment_method"
:
{
"barcode"
:"38100000000042290121213001160013"
,
"barcode_url"
:"http://s3.amazonaws.com/cash_payment_barcodes/"
\
"barcode_url"
:"http://s3.amazonaws.com/cash_payment_barcodes/"
+
"38100000000042290121213001160013.png"
,
"object"
:"cash_payment"
,
"type"
:"oxxo"
,
"expires_at"
:
1430006400
,
"store_name"
:"OXXO"
...
...
spec/spec_helper.rb
View file @
9a6022c
...
...
@@ -6,6 +6,7 @@ require 'var'
require
'mocks/var_database_mock'
require
'mocks/var_models_mock'
require
'mocks/webhooks_requests'
ActiveRecord
::
Base
.
establish_connection
(
adapter:
'sqlite3'
,
database:
':memory:'
)
...
...
spec/var_spec.rb
View file @
9a6022c
...
...
@@ -66,7 +66,7 @@ describe Var do
end
it
'handles card charge creation'
do
params
=
{
"data"
:
{
"object"
:
{
"id"
:
'5511d4ce2412294cf6000081'
,
"livemode"
:
false
,
"created_at"
:
1_427_231_950
,
"status"
:
'pending_payment'
,
"currency"
:
'MXN'
,
"description"
:
'Stogies'
,
"reference_id"
:
'9839-wolf_pack'
,
"failure_code"
:
nil
,
"failure_message"
:
nil
,
"monthly_installments"
:
nil
,
"object"
:
'charge'
,
"amount"
:
20_000
,
"paid_at"
:
nil
,
"fee"
:
963
,
"customer_id"
:
''
,
"refunds"
:
[],
"payment_method"
:
{
"name"
:
'Jorge Lopez'
,
"exp_month"
:
'12'
,
"exp_year"
:
'19'
,
"auth_code"
:
nil
,
"object"
:
'card_payment'
,
"last4"
:
'4242'
,
"brand"
:
'visa'
},
"details"
:
{
"name"
:
nil
,
"phone"
:
nil
,
"email"
:
nil
,
"line_items"
:
[]
}
},
"previous_attributes"
:
{}
},
"livemode"
:
false
,
"webhook_status"
:
'pending'
,
"id"
:
'5511d4ce2412294cf6000084'
,
"object"
:
'event'
,
"type"
:
'charge.created'
,
"created_at"
:
1_427_231_950
,
"webhook_logs"
:
[{
"id"
:
'webhl_nPzGMBeQmMUu7aQ'
,
"url"
:
'http://requestb.in/1em0jsx1'
,
"failed_attempts"
:
0
,
"last_http_response_status"
:
-
1
,
"object"
:
'webhook_log'
,
"last_attempted_at"
:
0
}]
}
params
=
WebHookPostRequest
::
CARD_CHARGE_CREATED
cardHandler
=
class_double
(
'Var::ConektaCardHandler'
)
.
as_stubbed_const
(
transfer_nested_constants:
true
)
expect
(
cardHandler
).
to
receive
(
:analyze
).
with
(
params
)
...
...
Please
register
or
login
to post a comment