This is a TDD workshop. Write the tests using outside in tests.
- Take turns. One write test, the other solves the test
- Code can only be ran with tests. No starting the code and use postman or similar
- Start with sunny days, then rainy days
- When writing test - Stop writing as soon as you have a red test.
- When writing code - Write the bare minimum code that satisfy the test.
protip(s)
- Do not test for things that are not there (they are infinite), test for things that are present.
Dont care about rights, users or authentication for now.
VERB | URL | Description |
---|---|---|
GET | /posts/:id | Get Single |
GET | /posts | Get List of |
POST | /posts | Create Single |
PUT | /posts/:id | Update Single |
DELETE | /posts/:id | Delete Single |
You should be able to create a blogpost by POSTing to the API. When GETing the blogpost by its id you should see the same post. If no blogpost is present, you should return 404. A blog post consists of a title and a text.
- ☀️ Create blog post
- ☀️ Read blog post
- ☁️ Read blog post but no blog post found
On a typical blog there is a index page which lists all the blog posts. Build the API endpoint for this page.
- ☀️ Read the list endpoint. Make sure it contains a newly created blog post.
- ☁️ Read the list endpoint. No posts should be present.
Title and text should be mandatory. The text cant be shorter than 10 chars. If it is you should show an error message and the post should not be present anywhere.
- ☁️ Create a blog post without anything. Make sure it is not accepted.
- ☁️ Create a blog post with a title but no body
- ☁️ Create a blog post with a body but no title
- ☁️ Create a blog post with a valid title but too short body
You should be able to update an existing post by PUTing to an endpoint. Title and text should still be mandatory and the text still can't be shorter than 10 chars. When the post is updated it should be reflected in the other endpoints.
- ☀️ Create a blog post. Update it and read it.
- ☁️
your on your own now
You should be able to delete an existing post by sending DELETE to an endpoint.
☀️, ☁️
Preferably make the comments be managed by a separate comments service which you mock out in the tests. If this is too hard, stick with database/in memory.
There should be a nested comments endpoint. (or an include=comments
query-parameter) (posts/:postid:/comments
). When viewing that the comments should be included. Comments can't be empty.
För att en användare ska få lämna en kommentar krävs att den anger en giltig emailadress. Annars ska ett felmeddelande visas.
Se till att email är unik för varje kommentar (per blogginlägg)
När en användare skriver ett blogginlägg kan den välja en kategori från en dropdown. Kategorierna måste vara en av de befintliga kategorierna (t.ex. %w{ fun education music film news misc }
) Kategorien ska vara obligatorisk.
En användare kan lägga till och ta bort kategorier i en speciellt vy. Det går även att byta namn på befintliga kategorier.