Ritarira / Books

0 stars 0 forks source link

Create API for authors #4

Closed Ritarira closed 6 years ago

Ritarira commented 6 years ago

User story: As an API consumer, I want to manage authors.

An author should have the following fields:

Acceptance criteria:

Ritarira commented 6 years ago

Test plan:

Ritarira commented 6 years ago

:white_check_mark: Check if I can get the full list of the authors with first and last names GET localhost:3000/authors Status 200

[
    {
        "id": 1,
        "first_name": "Colleen",
        "last_name": "Hoover",
        "created_at": "2017-12-04T07:30:10.762Z",
        "updated_at": "2017-12-04T07:30:10.762Z"
    },
    {
        "id": 2,
        "first_name": "Harper",
        "last_name": "Lee",
        "created_at": "2017-12-04T07:30:35.820Z",
        "updated_at": "2017-12-07T07:12:09.566Z"
    },
    ...
]
Ritarira commented 6 years ago

:white_check_mark: Check if I can get a single author with author's first and last names GET localhost:3000/authors/1 Status 200

{
    "id": 1,
    "first_name": "Colleen",
    "last_name": "Hoover",
    "created_at": "2017-12-04T07:30:10.762Z",
    "updated_at": "2017-12-04T07:30:10.762Z"
}

GET localhost:3000/authors/5 Status 200

{
    "id": 5,
    "first_name": "Vishen",
    "last_name": "Lakhiani",
    "created_at": "2017-12-07T07:03:10.493Z",
    "updated_at": "2017-12-07T07:03:10.493Z"
}
Ritarira commented 6 years ago

:white_check_mark: Check if I can make changes to author's first and last names Request: PUT localhost:3000/authors/5

{   

    "first_name": "John",
    "last_name": "Smith"

}

Response: Status 200

{
    "id": 5,
    "first_name": "John",
    "last_name": "Smith",
    "created_at": "2017-12-07T07:03:10.493Z",
    "updated_at": "2017-12-10T11:40:51.377Z"
}
Ritarira commented 6 years ago

:white_check_mark: Check if I can delete the author DELETE localhost:3000/authors/5 Status 204 GET localhost:3000/authors/5 Status 404

Ritarira commented 6 years ago

:white_check_mark: Check if I can create a new author with first and last names Request: POST localhost:3000/authors

{   

    "first_name": "Vishen",
    "last_name": "Lakhiani"

}

Response: Status 201

{
    "id": 12,
    "first_name": "Vishen",
    "last_name": "Lakhiani",
    "created_at": "2017-12-11T07:39:04.641Z",
    "updated_at": "2017-12-11T07:39:04.641Z"
}
Ritarira commented 6 years ago

:white_check_mark: Check what will happen if I don't add both author's first and last names while creating a new author POST localhost:3000/authors Status 422 :heavy_check_mark: first_name :heavy_check_mark: last_name

Ritarira commented 6 years ago

:white_check_mark: Check status codes of all valid responses

Ritarira commented 6 years ago

:white_check_mark: Check status codes when I delete/update a non-existing author Request: DELETE localhost:3000/authors/4 Response: Status 404

Request: PUT localhost:3000/authors/4

{   

        "first_name": "Mickael",
    "last_name": "Cooper"

}

Response: Status 404

Ritarira commented 6 years ago

:white_check_mark: Check the status code when I request a non-existing author GET localhost:3000/authors/5 Status 404

Ritarira commented 6 years ago

QA PASS