Fix tag drafts not being deleted upon creation / update#1867
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…r + renamed the latter to do_delete_draft
| @controller.stub('params', { tag_name: tag_name }) do | ||
| @controller.do_save_draft(user, draft_path) | ||
| end |
There was a problem hiding this comment.
This is an unfortunate mess, but doing this "the proper way" would require quite a bit of work that's outside of the scope of the PR (although I am not against making these changes if necessary): move all this to integration tests, move save_draft and delete_draft to concern's actions, etc.
| # @param tag_set [TagSet] tag set the tag belongs to | ||
| def try_create_tag(tag_set, category, **opts) | ||
| # this is needed for draft deletion until we switch from request.referer | ||
| @request.set_header('HTTP_REFERER', create_tag_path(id: category.id)) |
There was a problem hiding this comment.
And this is only here because we rely on request.referer when creating and deleting drafts. I'd like to work on switching from that approach separately, but open to doing it "while we are at it" too.
closes #1859
This PR adds a
DraftManagementconcern to both facilitate the fix and avoid duplication (all our controllers share the same draft saving & deletion logic). The concern is named this way to match Rails's convention of naming such controller concerns (see, for example,RequestForgeryProtection)