41 lines
2.5 KiB
Gherkin
41 lines
2.5 KiB
Gherkin
Feature: Deleting an article never deletes images
|
|
Superseded in part by roles_permissions_content_scope: the article routes are gated by the content.* permissions of the caller's role (content.create, content.update, content.delete and content.publish; a refusal is 403 "missing_permission" with the header X-Missing-Permission), and content.read decides which drafts show: every draft at all, only the caller's own drafts at own, none otherwise. A draft the caller may not read answers 404 "Article not found", and a role that cannot be resolved is treated as holding no permission.
|
|
|
|
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
|