mirror of
https://github.com/discourse/discourse.git
synced 2025-06-08 23:30:38 +08:00
FIX: Do not downcase group name in notification payload
Followup to 3d39b4bb
This commit is contained in:
@ -223,7 +223,7 @@ class PostAlerter
|
|||||||
topic.allowed_groups.map do |g|
|
topic.allowed_groups.map do |g|
|
||||||
{
|
{
|
||||||
group_id: g.id,
|
group_id: g.id,
|
||||||
group_name: g.name.downcase,
|
group_name: g.name,
|
||||||
inbox_count: DB.query_single(sql, group_id: g.id).first.to_i
|
inbox_count: DB.query_single(sql, group_id: g.id).first.to_i
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -71,19 +71,36 @@ describe PostAlerter do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "group inboxes" do
|
||||||
|
fab!(:user1) { Fabricate(:user) }
|
||||||
|
fab!(:user2) { Fabricate(:user) }
|
||||||
|
fab!(:group) { Fabricate(:group, users: [user2], name: "TestGroup") }
|
||||||
|
fab!(:pm) { Fabricate(:topic, archetype: 'private_message', category_id: nil, allowed_groups: [group]) }
|
||||||
|
fab!(:op) { Fabricate(:post, user: pm.user, topic: pm) }
|
||||||
|
|
||||||
it "triggers :before_create_notifications_for_users" do
|
it "triggers :before_create_notifications_for_users" do
|
||||||
pm = Fabricate(:topic, archetype: 'private_message', category_id: nil)
|
|
||||||
op = Fabricate(:post, user: pm.user, topic: pm)
|
|
||||||
user1 = Fabricate(:user)
|
|
||||||
user2 = Fabricate(:user)
|
|
||||||
group = Fabricate(:group, users: [user2])
|
|
||||||
pm.allowed_users << user1
|
pm.allowed_users << user1
|
||||||
pm.allowed_groups << group
|
|
||||||
events = DiscourseEvent.track_events do
|
events = DiscourseEvent.track_events do
|
||||||
PostAlerter.post_created(op)
|
PostAlerter.post_created(op)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(events).to include(event_name: :before_create_notifications_for_users, params: [[user1], op])
|
expect(events).to include(event_name: :before_create_notifications_for_users, params: [[user1], op])
|
||||||
expect(events).to include(event_name: :before_create_notifications_for_users, params: [[user2], op])
|
expect(events).to include(event_name: :before_create_notifications_for_users, params: [[user2], op])
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
it "triggers group summary notification" do
|
||||||
|
TopicUser.change(user2.id, pm.id, notification_level: TopicUser.notification_levels[:tracking])
|
||||||
|
|
||||||
|
PostAlerter.post_created(op)
|
||||||
|
group_summary_notification = Notification.where(user_id: user2.id)
|
||||||
|
|
||||||
|
expect(group_summary_notification.count).to eq(1)
|
||||||
|
expect(group_summary_notification.first.notification_type).to eq(Notification.types[:group_message_summary])
|
||||||
|
|
||||||
|
notification_payload = JSON.parse(group_summary_notification.first.data)
|
||||||
|
expect(notification_payload["group_name"]).to eq(group.name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user