FIX: error when changing a topic's category and creating a tag
This commit is contained in:
parent
339ddb8701
commit
29e733832d
|
@ -342,6 +342,8 @@ class TopicsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
invalid_tags = Tag.where_name(invalid_tags).pluck(:name)
|
||||
|
||||
if !invalid_tags.empty?
|
||||
if (invalid_tags & DiscourseTagging.hidden_tag_names).present?
|
||||
return render_json_error(I18n.t('category.errors.disallowed_tags_generic'))
|
||||
|
|
|
@ -1038,6 +1038,32 @@ RSpec.describe TopicsController do
|
|||
expect(topic.tags.pluck(:id)).to contain_exactly(tag.id)
|
||||
end
|
||||
|
||||
it "can create a tag" do
|
||||
SiteSetting.min_trust_to_create_tag = 0
|
||||
expect do
|
||||
put "/t/#{topic.slug}/#{topic.id}.json", params: {
|
||||
tags: ["newtag"]
|
||||
}
|
||||
end.to change { topic.reload.first_post.revisions.count }.by(1)
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(topic.reload.tags.pluck(:name)).to contain_exactly("newtag")
|
||||
end
|
||||
|
||||
it "can change the category and create a new tag" do
|
||||
SiteSetting.min_trust_to_create_tag = 0
|
||||
category = Fabricate(:category)
|
||||
expect do
|
||||
put "/t/#{topic.slug}/#{topic.id}.json", params: {
|
||||
tags: ["newtag"],
|
||||
category_id: category.id
|
||||
}
|
||||
end.to change { topic.reload.first_post.revisions.count }.by(1)
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(topic.reload.tags.pluck(:name)).to contain_exactly("newtag")
|
||||
end
|
||||
|
||||
it "can add a tag to wiki topic" do
|
||||
SiteSetting.min_trust_to_edit_wiki_post = 2
|
||||
topic.first_post.update!(wiki: true)
|
||||
|
|
Loading…
Reference in New Issue