Compare commits

..

No commits in common. "ca926d9adad69585d740fecd616b85d1a86206fb" and "98c89f6247fb9a039d75b82895d517b7900cf8b8" have entirely different histories.

4 changed files with 7 additions and 20 deletions

View File

@ -254,7 +254,7 @@ public class RecipesControllerTests {
final String updateBody = this.objectMapper.writeValueAsString(spec);
this.mockMvc.perform(
put("/recipes/{username}/{slug}", owner.getUsername(), recipe.getSlug())
post("/recipes/{username}/{slug}", owner.getUsername(), recipe.getSlug())
.header("Authorization", "Bearer " + this.getAccessToken(owner))
.contentType(MediaType.APPLICATION_JSON)
.content(updateBody)
@ -318,7 +318,7 @@ public class RecipesControllerTests {
final String accessToken = this.getAccessToken(owner);
this.mockMvc.perform(
put("/recipes/{username}/{slug}", owner.getUsername(), recipe.getSlug())
post("/recipes/{username}/{slug}", owner.getUsername(), recipe.getSlug())
.header("Authorization", "Bearer " + accessToken)
.contentType(MediaType.APPLICATION_JSON)
.content(body)

View File

@ -368,7 +368,7 @@ public class RecipeService {
public Recipe publishDraft(UUID draftId, User modifier) {
final RecipeDraft recipeDraft = this.recipeDraftRepository.findById(draftId)
.orElseThrow(() -> new NoSuchEntityWithIdException(RecipeDraft.class, draftId));
final var b = RecipeCreateSpec.builder()
final RecipeCreateSpec spec = RecipeCreateSpec.builder()
.slug(recipeDraft.getSlug())
.title(recipeDraft.getTitle())
.preparationTime(recipeDraft.getPreparationTime())
@ -376,21 +376,8 @@ public class RecipeService {
.totalTime(recipeDraft.getTotalTime())
.rawText(recipeDraft.getRawText())
.isPublic(false)
.mainImage(recipeDraft.getMainImage());
if (recipeDraft.getIngredients() != null) {
b.ingredients(recipeDraft.getIngredients().stream()
.map(ingredientDraft -> RecipeCreateSpec.IngredientCreateSpec.builder()
.amount(ingredientDraft.getAmount())
.name(ingredientDraft.getName())
.notes(ingredientDraft.getNotes())
.build()
)
.toList()
);
}
final RecipeCreateSpec spec = b.build();
.mainImage(recipeDraft.getMainImage())
.build();
final Recipe recipe = this.create(recipeDraft.getOwner(), spec, true);
this.recipeDraftRepository.deleteById(draftId); // delete old draft
return recipe;

View File

@ -66,7 +66,7 @@ public class RecipesController {
return ResponseEntity.ok(this.getFullViewWrapper(username, slug, view, viewer));
}
@PutMapping("/{username}/{slug}")
@PostMapping("/{username}/{slug}")
public ResponseEntity<Map<String, Object>> updateByUsernameAndSlug(
@PathVariable String username,
@PathVariable String slug,

View File

@ -13,7 +13,7 @@ import java.time.OffsetDateTime;
public class RecipeInfoView {
Integer id;
OffsetDateTime created;
@Nullable OffsetDateTime modified;
OffsetDateTime modified;
String slug;
String title;
@Nullable Integer preparationTime;