Updating Recipe Loses PublishedAt
rickydodd opened this issue · 0 comments
rickydodd commented
When a PUT request is made on a recipe, the PublishedAt is set to the default of time.Time.
To reproduce:
- POST a recipe (or use the recipes from the recipes.json file).
- Issue a PUT request to
http://localhost:8080/:id
, where:id
is replaced with the ID of the previously POST'd recipe. - Examine the
publishedAt
JSON name-value pair, it will not be the time of the POST'd recipe.
An automatic reproduction (requires bash, grep, and jq, and also sets a temporary bash variable):
1.
bdaig_var=$(curl -s -L -X POST 'http://localhost:8080/recipes' \
--header 'Content-Type: application/json' --data-raw '{
"name": "Lorem ipsum",
"tags": ["dolor", "sit", "amet"],
"ingredients": [
"consectetur",
"adipiscing",
"elit"
],
"instructions":
[
"Quisque",
"eget",
"nisl"
]
}' | jq -r | grep -o -P '(?<="id": ").*(?=",)')
curl -L -X PUT 'http://localhost:8080/recipes/'$bdaig_var \
--header 'Content-Type: application/json' --data-raw '{
"name": "Lorem ipsum",
"tags": ["dolor", "sit", "amet"],
"ingredients": [
"consectetur",
"adipiscing",
"elit"
],
"instructions":
[
"Quisque",
"eget",
"nisl"
]
}' | jq -r
- Inspect the
publishedAt
JSON key-value pair. The value will not be the time the first command was ran.