Skip to content

A platform for community discussion. Free, open, simple.

FIX: Include user id in notification webhook (#8195)

Blake Ericksonef0fe51e05f3
diff --git a/app/serializers/notification_serializer.rb b/app/serializers/notification_serializer.rb
index 34780b86a6e..e01e639b457 100644
--- a/app/serializers/notification_serializer.rb
+++ b/app/serializers/notification_serializer.rb
@@ -3,6 +3,7 @@
class NotificationSerializer < ApplicationSerializer
attributes :id,
+ :user_id,
:notification_type,
:read,
:created_at,
diff --git a/spec/serializers/notification_serializer_spec.rb b/spec/serializers/notification_serializer_spec.rb
new file mode 100644
index 00000000000..63f305e00c4
--- /dev/null
+++ b/spec/serializers/notification_serializer_spec.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+describe NotificationSerializer do
+ describe '#as_json' do
+ fab!(:user) { Fabricate(:user) }
+ let(:notification) { Fabricate(:notification, user: user) }
+ let(:serializer) { NotificationSerializer.new(notification) }
+ let(:json) { serializer.as_json }
+
+ it "returns the user_id" do
+ expect(json[:notification][:user_id]).to eq(user.id)
+ end
+
+ end
+end