mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: corrently handle hidden tags when checking for edit conflicts
In 806e37aaec, I improved the conflict handling when editing a post to account for title and tags.
This fixes an edge cases when a topic has a hidden tag the current editor can't see. When they submit their edit, we automatically add the hidden tags before checking with the tags stored in the database.
Reported in https://meta.discourse.org/t/341375
This commit is contained in:
@@ -164,6 +164,39 @@ RSpec.describe DraftsController do
|
||||
expect(response.parsed_body["conflict_user"]["id"]).to eq(post.last_editor.id)
|
||||
end
|
||||
|
||||
it "handles hidden tags when checking for tag conflict" do
|
||||
sign_in(user)
|
||||
|
||||
regular_tag = Fabricate(:tag)
|
||||
admin_only_tag_one = Fabricate(:tag)
|
||||
admin_only_tag_two = Fabricate(:tag)
|
||||
|
||||
admin_only_tag_group = Fabricate(:tag_group)
|
||||
admin_only_tag_group.tags = [admin_only_tag_one, admin_only_tag_two]
|
||||
admin_only_tag_group.permissions = [
|
||||
[Group::AUTO_GROUPS[:admins], TagGroupPermission.permission_types[:full]],
|
||||
]
|
||||
admin_only_tag_group.save!
|
||||
|
||||
post = Fabricate(:post, user:)
|
||||
post.topic.tags = [regular_tag, admin_only_tag_one]
|
||||
|
||||
post "/drafts.json",
|
||||
params: {
|
||||
draft_key: "topic",
|
||||
sequence: 0,
|
||||
data: {
|
||||
postId: post.id,
|
||||
original_text: post.raw,
|
||||
original_tags: [regular_tag.name],
|
||||
action: "edit",
|
||||
}.to_json,
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(response.parsed_body["conflict_user"]).to eq(nil)
|
||||
end
|
||||
|
||||
it "cant trivially resolve conflicts without interaction" do
|
||||
sign_in(user)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user