mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
Revert "DEV: Removal of create_post_for_category_and_tag_changes setting (#28…" (#28587)
This reverts commit fc33826dc55e1e6427eea7adb005e4aed45ccba5.
This commit is contained in:
@ -222,6 +222,87 @@ RSpec.describe PostRevisor do
|
||||
|
||||
expect { post_revisor.revise!(admin, tags: ["new-tag"]) }.not_to change { Notification.count }
|
||||
end
|
||||
|
||||
it "doesn't create a small_action post when create_post_for_category_and_tag_changes is false" do
|
||||
SiteSetting.create_post_for_category_and_tag_changes = false
|
||||
|
||||
expect { post_revisor.revise!(admin, tags: ["new-tag"]) }.not_to change { Post.count }
|
||||
end
|
||||
|
||||
describe "when `create_post_for_category_and_tag_changes` site setting is enabled" do
|
||||
fab!(:tag1) { Fabricate(:tag, name: "First tag") }
|
||||
fab!(:tag2) { Fabricate(:tag, name: "Second tag") }
|
||||
|
||||
before { SiteSetting.create_post_for_category_and_tag_changes = true }
|
||||
|
||||
it "Creates a small_action post with correct translation when both adding and removing tags" do
|
||||
post.topic.update!(tags: [tag1])
|
||||
|
||||
expect { post_revisor.revise!(admin, tags: [tag2.name]) }.to change {
|
||||
Post.where(topic_id: post.topic_id, action_code: "tags_changed").count
|
||||
}.by(1)
|
||||
|
||||
expect(post.topic.ordered_posts.last.raw).to eq(
|
||||
I18n.t(
|
||||
"topic_tag_changed.added_and_removed",
|
||||
added: "##{tag2.name}",
|
||||
removed: "##{tag1.name}",
|
||||
),
|
||||
)
|
||||
end
|
||||
|
||||
it "Creates a small_action post with correct translation when adding tags" do
|
||||
post.topic.update!(tags: [])
|
||||
|
||||
expect { post_revisor.revise!(admin, tags: [tag1.name]) }.to change {
|
||||
Post.where(topic_id: post.topic_id, action_code: "tags_changed").count
|
||||
}.by(1)
|
||||
|
||||
expect(post.topic.ordered_posts.last.raw).to eq(
|
||||
I18n.t("topic_tag_changed.added", added: "##{tag1.name}"),
|
||||
)
|
||||
end
|
||||
|
||||
it "Creates a small_action post with correct translation when removing tags" do
|
||||
post.topic.update!(tags: [tag1, tag2])
|
||||
|
||||
expect { post_revisor.revise!(admin, tags: []) }.to change {
|
||||
Post.where(topic_id: post.topic_id, action_code: "tags_changed").count
|
||||
}.by(1)
|
||||
|
||||
expect(post.topic.ordered_posts.last.raw).to eq(
|
||||
I18n.t("topic_tag_changed.removed", removed: "##{tag1.name}, ##{tag2.name}"),
|
||||
)
|
||||
end
|
||||
|
||||
it "Creates a small_action post when category is changed" do
|
||||
current_category = post.topic.category
|
||||
category = Fabricate(:category)
|
||||
|
||||
expect { post_revisor.revise!(admin, category_id: category.id) }.to change {
|
||||
Post.where(topic_id: post.topic_id, action_code: "category_changed").count
|
||||
}.by(1)
|
||||
|
||||
expect(post.topic.ordered_posts.last.raw).to eq(
|
||||
I18n.t(
|
||||
"topic_category_changed",
|
||||
to: "##{category.slug}",
|
||||
from: "##{current_category.slug}",
|
||||
),
|
||||
)
|
||||
end
|
||||
|
||||
describe "with PMs" do
|
||||
fab!(:pm) { Fabricate(:private_message_topic) }
|
||||
let(:first_post) { create_post(user: admin, topic: pm, allow_uncategorized_topics: false) }
|
||||
fab!(:category) { Fabricate(:category, topic_count: 1) }
|
||||
it "Does not create a category change small_action post when converting to a topic" do
|
||||
expect do
|
||||
TopicConverter.new(first_post.topic, admin).convert_to_public_topic(category.id)
|
||||
end.to change { category.reload.topic_count }.by(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "revise wiki" do
|
||||
|
Reference in New Issue
Block a user