mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Create post actions without creating a notification and store custom data. (#15397)
I plan to use this in an upcoming discourse-reactions PR, where I want to like a post without notifying the user, so I can instead create a reaction notification. Additionally, we decouple the a11y attributes from the icon itself, which will let us extend the widget's icon without losing them.
This commit is contained in:
@@ -1869,4 +1869,21 @@ describe PostAlerter do
|
||||
expect(email).to eq(last_email)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'storing custom data' do
|
||||
let(:custom_data) { 'custom_string' }
|
||||
|
||||
it 'stores custom data inside a notification' do
|
||||
PostAlerter.new.create_notification(
|
||||
admin,
|
||||
Notification.types[:liked],
|
||||
post,
|
||||
custom_data: { custom_key: custom_data }
|
||||
)
|
||||
|
||||
liked_notification = Notification.where(notification_type: Notification.types[:liked]).last
|
||||
|
||||
expect(liked_notification.data_hash[:custom_key]).to eq(custom_data)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user