mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 20:54:31 +08:00
Merge pull request #6106 from OsamaSayegh/watch-when-splitting
FIX: topic owner should watch the new topic when moving posts to a new topic
This commit is contained in:
commit
7cf6c2825e
|
@ -34,6 +34,8 @@ class PostMover
|
|||
)
|
||||
DiscourseTagging.tag_topic_by_names(new_topic, Guardian.new(user), tags)
|
||||
move_posts_to new_topic
|
||||
watch_new_topic
|
||||
new_topic
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -223,4 +225,13 @@ class PostMover
|
|||
destination_topic.update_columns(attrs)
|
||||
end
|
||||
end
|
||||
|
||||
def watch_new_topic
|
||||
TopicUser.change(
|
||||
destination_topic.user,
|
||||
destination_topic.id,
|
||||
notification_level: TopicUser.notification_levels[:watching],
|
||||
notifications_reason_id: TopicUser.notification_reasons[:created_topic]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -264,6 +264,19 @@ describe PostMover do
|
|||
moderator_post = topic.posts.last
|
||||
expect(moderator_post.raw).to include("2 posts were split")
|
||||
end
|
||||
|
||||
it "forces resulting topic owner to watch the new topic" do
|
||||
new_topic = topic.move_posts(user, [p2.id, p4.id], title: "new testing topic name", category_id: category.id)
|
||||
|
||||
expect(new_topic.posts_count).to eq(2)
|
||||
|
||||
expect(TopicUser.exists?(
|
||||
user_id: another_user,
|
||||
topic_id: new_topic.id,
|
||||
notification_level: TopicUser.notification_levels[:watching],
|
||||
notifications_reason_id: TopicUser.notification_reasons[:created_topic]
|
||||
)).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
context "to an existing topic" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user