mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 11:52:45 +08:00
FIX: Don't update watching_first_post
notifications when moving first post
The first post isn't moved. It gets copied during a move. Notifications of this special type should still link to the original first post.
This commit is contained in:
parent
5981678abd
commit
2a95c5c5d6
|
@ -238,6 +238,7 @@ class PostMover
|
|||
)) :: JSON
|
||||
FROM moved_posts mp
|
||||
WHERE n.topic_id = mp.old_topic_id AND n.post_number = mp.old_post_number
|
||||
AND n.notification_type <> #{Notification.types[:watching_first_post]}
|
||||
SQL
|
||||
end
|
||||
|
||||
|
|
|
@ -72,3 +72,17 @@ Fabricator(:mentioned_notification, from: :notification) do
|
|||
}.to_json
|
||||
end
|
||||
end
|
||||
|
||||
Fabricator(:watching_first_post_notification, from: :notification) do
|
||||
notification_type Notification.types[:watching_first_post]
|
||||
data do |attrs|
|
||||
{
|
||||
topic_title: attrs[:topic].title,
|
||||
original_post_id: attrs[:post].id,
|
||||
original_post_type: attrs[:post].post_type,
|
||||
original_username: attrs[:post].user.username,
|
||||
revision_number: nil,
|
||||
display_username: attrs[:post].user.username
|
||||
}.to_json
|
||||
end
|
||||
end
|
||||
|
|
|
@ -312,6 +312,17 @@ describe PostMover do
|
|||
expect(n4.post_number).to eq(4)
|
||||
end
|
||||
|
||||
it "doesn't update notifications of type 'watching_first_post'" do
|
||||
n1 = Fabricate(:watching_first_post_notification, post: p1, user: another_user)
|
||||
|
||||
topic.move_posts(user, [p1.id], title: "new testing topic name")
|
||||
|
||||
n1.reload
|
||||
expect(n1.topic_id).to eq(topic.id)
|
||||
expect(n1.data_hash[:topic_title]).to eq(topic.title)
|
||||
expect(n1.post_number).to eq(1)
|
||||
end
|
||||
|
||||
it "deletes notifications for users not allowed to see the topic" do
|
||||
another_admin = Fabricate(:admin)
|
||||
staff_category = Fabricate(:private_category, group: Group[:staff])
|
||||
|
|
Loading…
Reference in New Issue
Block a user