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

Spec dispute documents #571

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions features/rest/disputes.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,21 @@ Feature: Disputes occur when customers dispute transactions
When I GET to /disputes
Then I should get a 200 OK status code
And the response is valid according to the "disputes" schema

Scenario: Retrieve a dispute document
Given I have a dispute with submitted documents
When I GET to /dispute_documents/:dispute_document_id
Copy link
Contributor

Choose a reason for hiding this comment

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

@steveklabnik do you like dispute_documents vs evidence? What's your reasoning for choosing one over the other?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pluralization of evidence was what steered me away from using it as a resource name.

Copy link
Contributor

Choose a reason for hiding this comment

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

"evidence" can be evidence of anything, "dispute document" is extremely unambiguous.

I don't feel particularly strongly about it, though.

Then I should get a 200 OK status code
And the response is valid according to the "dispute_document" schema

Scenario: List dispute documents for a dispute
Given I have a dispute with submitted documents
When I GET to /disputes/:dispute_id/dispute_documents
Then I should get a 200 OK status code
And the response is valid according to the "dispute_documents" schema

Scenario: List dispute documents
Given I have a dispute with submitted documents
When I GET to /dispute_documents
Then I should get a 200 OK status code
And the response is valid according to the "dispute_documents" schema
38 changes: 38 additions & 0 deletions features/step_definitions/disputes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,41 @@
raise 'Unable to get a dispute in 3 minutes' if count == 0
@client.add_hydrate(:dispute_id, @dispute_id)
end

Given(/^I have a customer who will dispute any charge and I intend to disprove$/) do
step "I have created a customer"
@client.post('/cards',
{
number: "6500000000000003",
expiration_month: 12,
expiration_year: 3000,
cvv: "123",
customer: @customer_id
}
)
@dispute_card_id = @client['cards']['id']
@client.add_hydrate(:dispute_card_id, @dispute_card_id)
end

Given(/^I have debited a card that will initiate a dispute with submitted documents$/) do
step "I have a customer who will dispute any charge and I intend to disprove"
@client.post("/cards/#{@dispute_card_id}/debits", {
'amount' => 99999
})
@disputed_debit_id = @client['debits']['id']
@client.add_hydrate(:disputed_debit_id, @disputed_debit_id)
end

Given(/^I have a dispute with submitted documents$/) do
step 'I have debited a card that will initiate a dispute with submitted documents'
@dispute_id = nil
count = 60
while @dispute_id.nil? and count > 0
Copy link
Contributor

Choose a reason for hiding this comment

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

@remear what do you think about removing this polling shit and tasking someone to fix the dispute latency? this is a cancer across all our specs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

anigif_enhanced-buzz-30309-1388524076-1

Completely agree. This polling stuff horrible.

count -= 1
@client.get("/debits/#{@disputed_debit_id}")
@dispute_id = @client['debits']['links']['dispute']
sleep 3
end
raise 'Unable to get a dispute in 3 minutes' if count == 0
@client.add_hydrate(:dispute_id, @dispute_id)
end
4 changes: 4 additions & 0 deletions fixtures/_models/dispute.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
"type": "string",
"format": "date-time"
},
"documentation_submitted_at": {
"type": "string",
"format": "date-time"
},
"meta": {
"$ref": "meta.json"
},
Expand Down
77 changes: 77 additions & 0 deletions fixtures/_models/dispute_document.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"id": {
"type": "string",
"pattern": "DD[a-zA-Z0-9]{16,32}"
},
"href": {
"type": "string",
"format": "uri"
},
"created_at": {
"type": "string",
"format": "date-time"
},
"updated_at": {
"type": "string",
"format": "date-time"
},
"url": {
"description": "The url where the file may be accessed",
"type": "string",
"format": "uri"
},
"mime_type": {
"type": "string",
"enum": [
"application/pdf",
"application/msword",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"image/jpeg"
Copy link
Contributor

Choose a reason for hiding this comment

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

pngs too? my mac creates a png everytime i take a screenshot

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In #563 (comment) it was stated that the only image format AMEX accepts is jpeg.

]
},
"file_name": {
"description": "Name of the document",
"type": "string"
},
"file_size": {
"description": "Size on disk of the document",
"type": "integer"
},
"meta": {
"$ref": "meta.json"
},
"links": {
"type": "object",
"properties": {
"dispute": {
"description": "The dispute the customer has filed with their bank associated with this debit",
"type": [
"null",
"string"
],
"pattern": "DT[a-zA-Z0-9]{16,32}"
}
},
"additionalProperties": false,
"required": [
"dispute"
]
}
},
"additionalProperties": false,
"required": [
"id",
"href",
"created_at",
"updated_at",
"url",
"mime_type",
"file_name",
"file_size",
"meta",
"links"
]
}
24 changes: 24 additions & 0 deletions fixtures/dispute_documents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"links": {
"type": "object",
"properties": {}
Copy link
Contributor

Choose a reason for hiding this comment

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

this needs a dispute_document.dispute reference

},
"meta": {
"type": "object"
},
"dispute_documents": {
"items": {
"$ref": "_models/dispute_document.json"
},
"type": "array",
"minItems": 0,
"uniqueItems": true
}
},
"required": [
"dispute_documents"
]
}
8 changes: 7 additions & 1 deletion fixtures/disputes.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@
"type": "string",
"format": "uri",
"pattern": "/disputes/{disputes.id}/events"
},
"disputes.dispute_documents": {
"type": "string",
"format": "uri",
"pattern": "/disputes/{disputes.id}/dispute_documents"
}
},
"required": [
"disputes.transaction",
"disputes.events"
"disputes.events",
"disputes.dispute_documents"
]
},
"meta": {
Expand Down