feat(API): media library
This commit is contained in:
1 parent
95ae043d3e
commit
0d99544579
65 files changed
+3992
-1530
No files matched your search
@@ -0,0 +1,39 @@
|
||||
Feature: Deleting an article never deletes images
|
||||
|
||||
As an authenticated RenewCMS user
|
||||
I want deleting an article to leave the media library alone
|
||||
So that an image used by other articles, or waiting in the library, is never lost
|
||||
|
||||
Background:
|
||||
Given images belong to the library and internal/domain/article.Article carries no Images
|
||||
And DeleteArticleUseCase depends only on article.Repository and calls its Delete
|
||||
And api/dependecyInjection.go builds useCases.NewDeleteArticleUseCase(repos.ArticleRepo)
|
||||
And DELETE /v1/article/{id} stays behind the same jwtauth group, answering 204 with an
|
||||
empty body, 404 with apperr.ArticleNotFoundErrorMessage for errors.Is(err,
|
||||
article.ErrArticleNotFound), and the generic 500 "Failed to delete article" otherwise
|
||||
|
||||
Scenario: Deleting an article leaves every image it used
|
||||
Given a valid jwt cookie for user 1
|
||||
And article 1 whose body contains the urls of images 10 and 11
|
||||
And the image repository contains images 10 and 11
|
||||
When the client sends DELETE /v1/article/1
|
||||
Then the response status is 204
|
||||
And the article repository no longer contains article 1
|
||||
And the image repository still contains images 10 and 11 and Delete was never called
|
||||
|
||||
Scenario: Deleting an unknown article is 404 and touches no image
|
||||
Given a valid jwt cookie for user 1 and no article 9999
|
||||
When the client sends DELETE /v1/article/9999
|
||||
Then the response status is 404 and the body is "Article not found"
|
||||
And the image repository is untouched
|
||||
|
||||
Scenario: Deleting still requires authentication
|
||||
Given no jwt cookie
|
||||
When the client sends DELETE /v1/article/1
|
||||
Then the response status is 401 and article 1 and image 10 still exist
|
||||
|
||||
Scenario: An article repository failure is 500 and everything stays
|
||||
Given the article repository's Delete fails
|
||||
When the client sends DELETE /v1/article/1 with a valid cookie
|
||||
Then the response status is 500 and the body is "Failed to delete article"
|
||||
And the image repository is untouched
|
||||
Reference in new issue
Block a user