-
-
Notifications
You must be signed in to change notification settings - Fork 71
Fix tag drafts not being deleted upon creation / update #1867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
25f2631
fixed tag drafts not being deleted upon creation / update
Oaphi d6b9456
moved draft save logic to DraftManagement concern
Oaphi d358a18
remove accidental test log from the tag create action
Oaphi df5a001
added User#can_edit_tags? predicate
Oaphi 4e15c3c
added tests for tag create action
Oaphi 4949ba8
added test user specifically for the edit_tags ability
Oaphi 9ef75b6
don't forget that tag editors are 'everyone' too
Oaphi c06cc02
reworked do_save_draft & do_draft_delete to not depend on current_use…
Oaphi c01a33e
added testing for draft deletion when creating tags
Oaphi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,12 +111,21 @@ class TagsControllerTest < ActionController::TestCase | |
|
|
||
| users.each do |user| | ||
| sign_in(user) | ||
| try_create_tag(category, tag_set, name: "test-tag-#{user.id}") | ||
|
|
||
| draft_path = create_tag_path(id: category.id) | ||
| tag_name = "test-tag-#{user.id}" | ||
|
|
||
| @controller.stub('params', { tag_name: tag_name }) do | ||
| @controller.do_save_draft(user, draft_path) | ||
| end | ||
|
|
||
| try_create_tag(category, tag_set, name: tag_name) | ||
|
|
||
| if !@controller.helpers.user_signed_in? | ||
| assert_redirected_to_sign_in | ||
| elsif user.can_edit_tags? | ||
| assert_response(:found, "Expected user '#{user.name}' to be able to create tags") | ||
| assert_draft_deleted(user, draft_path, :tag_name) | ||
| else | ||
| assert_response(:not_found, "Expected user '#{user.name}' to not be able to create tags") | ||
| end | ||
|
|
@@ -276,6 +285,9 @@ class TagsControllerTest < ActionController::TestCase | |
| # @param category [Category] category to create the tag in | ||
| # @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)) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And this is only here because we rely on |
||
|
|
||
| post :create, params: { | ||
| id: category.id, | ||
| tag: { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_draftanddelete_draftto concern's actions, etc.