mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 03:10:46 -06:00
FIX: Show suspended by user (#16927)
- Show "suspended by" user - Add specs for silence user
This commit is contained in:
parent
cd0f912159
commit
7a223331d1
@ -150,7 +150,8 @@ class Admin::UsersController < Admin::AdminController
|
||||
suspend_reason: params[:reason],
|
||||
full_suspend_reason: user_history.try(:details),
|
||||
suspended_till: @user.suspended_till,
|
||||
suspended_at: @user.suspended_at
|
||||
suspended_at: @user.suspended_at,
|
||||
suspended_by: BasicUserSerializer.new(current_user, root: false).as_json
|
||||
}
|
||||
)
|
||||
end
|
||||
|
@ -162,6 +162,7 @@ RSpec.describe Admin::UsersController do
|
||||
expect(user).to be_suspended
|
||||
expect(user.suspended_at).to be_present
|
||||
expect(user.suspended_till).to be_present
|
||||
expect(user.suspend_record).to be_present
|
||||
|
||||
log = UserHistory.where(target_user_id: user.id).order('id desc').first
|
||||
expect(log.details).to match(/because I said so/)
|
||||
@ -896,6 +897,7 @@ RSpec.describe Admin::UsersController do
|
||||
expect(response.status).to eq(200)
|
||||
reg_user.reload
|
||||
expect(reg_user).to be_silenced
|
||||
expect(reg_user.silenced_record).to be_present
|
||||
end
|
||||
|
||||
it "can have an associated post" do
|
||||
|
20
spec/requests/api/schemas/json/user_silence_request.json
Normal file
20
spec/requests/api/schemas/json/user_silence_request.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"silenced_till": {
|
||||
"type": "string",
|
||||
"example": "2022-06-01T08:00:00.000Z"
|
||||
},
|
||||
"reason": {
|
||||
"type": "string"
|
||||
},
|
||||
"message": {
|
||||
"type": "string",
|
||||
"description": "Will send an email with this message when present"
|
||||
},
|
||||
"post_action": {
|
||||
"type": "string",
|
||||
"example": "delete"
|
||||
}
|
||||
}
|
||||
}
|
52
spec/requests/api/schemas/json/user_silence_response.json
Normal file
52
spec/requests/api/schemas/json/user_silence_response.json
Normal file
@ -0,0 +1,52 @@
|
||||
{
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"silence": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"silenced": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"silence_reason": {
|
||||
"type": "string"
|
||||
},
|
||||
"silenced_till": {
|
||||
"type": "string"
|
||||
},
|
||||
"silenced_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"silenced_by": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"avatar_template": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["id", "username", "name", "avatar_template"]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"silenced",
|
||||
"silence_reason",
|
||||
"silenced_till",
|
||||
"silenced_at",
|
||||
"silenced_by"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"silence"
|
||||
]
|
||||
}
|
@ -16,13 +16,33 @@
|
||||
},
|
||||
"suspended_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"suspended_by": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"avatar_template": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["id", "username", "name", "avatar_template"]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"suspend_reason",
|
||||
"full_suspend_reason",
|
||||
"suspended_till",
|
||||
"suspended_at"
|
||||
"suspended_at",
|
||||
"suspended_by"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -400,6 +400,33 @@ describe 'users' do
|
||||
end
|
||||
end
|
||||
|
||||
path '/admin/users/{id}/silence.json' do
|
||||
put 'Silence a user' do
|
||||
tags 'Users', 'Admin'
|
||||
operationId 'silenceUser'
|
||||
consumes 'application/json'
|
||||
expected_request_schema = load_spec_schema('user_silence_request')
|
||||
|
||||
parameter name: :id, in: :path, type: :integer, required: true
|
||||
parameter name: :params, in: :body, schema: expected_request_schema
|
||||
|
||||
produces 'application/json'
|
||||
response '200', 'response' do
|
||||
|
||||
let(:id) { Fabricate(:user).id }
|
||||
let(:params) {}
|
||||
|
||||
expected_response_schema = load_spec_schema('user_silence_response')
|
||||
schema(expected_response_schema)
|
||||
|
||||
it_behaves_like "a JSON endpoint", 200 do
|
||||
let(:expected_response_schema) { expected_response_schema }
|
||||
let(:expected_request_schema) { expected_request_schema }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
path '/admin/users/{id}/anonymize.json' do
|
||||
put 'Anonymize a user' do
|
||||
tags 'Users', 'Admin'
|
||||
|
Loading…
Reference in New Issue
Block a user