2020-08-08 04:28:47 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
require "swagger_helper"
|
|
|
|
|
2022-07-28 10:27:38 +08:00
|
|
|
RSpec.describe "notifications" do
|
2020-08-08 04:28:47 +08:00
|
|
|
let(:admin) { Fabricate(:admin) }
|
|
|
|
let!(:notification) { Fabricate(:notification, user: admin) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
Jobs.run_immediately!
|
|
|
|
sign_in(admin)
|
|
|
|
end
|
|
|
|
|
|
|
|
path "/notifications.json" do
|
|
|
|
get "Get the notifications that belong to the current user" do
|
|
|
|
tags "Notifications"
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId "getNotifications"
|
2020-08-08 04:28:47 +08:00
|
|
|
|
|
|
|
produces "application/json"
|
|
|
|
response "200", "notifications" do
|
|
|
|
schema type: :object,
|
|
|
|
properties: {
|
|
|
|
notifications: {
|
|
|
|
type: :array,
|
|
|
|
items: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
id: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
user_id: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
notification_type: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
read: {
|
|
|
|
type: :boolean,
|
|
|
|
},
|
|
|
|
created_at: {
|
2021-08-13 02:25:17 +08:00
|
|
|
type: :string,
|
|
|
|
},
|
|
|
|
post_number: {
|
2024-04-10 23:29:03 +08:00
|
|
|
type: %i[integer null],
|
2021-08-13 02:25:17 +08:00
|
|
|
},
|
|
|
|
topic_id: {
|
|
|
|
type: %i[integer null],
|
|
|
|
},
|
|
|
|
slug: {
|
|
|
|
type: %i[string null],
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
2020-08-08 04:28:47 +08:00
|
|
|
data: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
badge_id: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
badge_name: {
|
|
|
|
type: :string,
|
|
|
|
},
|
|
|
|
badge_slug: {
|
|
|
|
type: :string,
|
|
|
|
},
|
|
|
|
badge_title: {
|
|
|
|
type: :boolean,
|
|
|
|
},
|
|
|
|
username: {
|
|
|
|
type: :string,
|
|
|
|
},
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
2020-08-08 04:28:47 +08:00
|
|
|
},
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
2020-08-08 04:28:47 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
total_rows_notifications: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
seen_notification_id: {
|
|
|
|
type: :integer,
|
|
|
|
},
|
|
|
|
load_more_notifications: {
|
|
|
|
type: :string,
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
2020-08-08 04:28:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
run_test!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
path "/notifications/mark-read.json" do
|
|
|
|
put "Mark notifications as read" do
|
|
|
|
tags "Notifications"
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId "markNotificationsAsRead"
|
2020-08-08 04:28:47 +08:00
|
|
|
consumes "application/json"
|
|
|
|
parameter name: :notification,
|
|
|
|
in: :body,
|
|
|
|
schema: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
id: {
|
|
|
|
type: :integer,
|
|
|
|
description: "(optional) Leave off to mark all notifications as read",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
produces "application/json"
|
|
|
|
response "200", "notifications marked read" do
|
|
|
|
schema type: :object, properties: { success: { type: :string } }
|
|
|
|
|
|
|
|
run_test!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|