mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
FIX: Show error message if user is already silenced or suspended (#10988)
Users could be silenced or suspended by two staff members at the same time and would not be aware of it. This commit shows an error message if another penalty has been applied.
This commit is contained in:
@ -149,6 +149,27 @@ RSpec.describe Admin::UsersController do
|
||||
expect(log.details).to match(/because I said so/)
|
||||
end
|
||||
|
||||
it "checks if user is suspended" do
|
||||
put "/admin/users/#{user.id}/suspend.json", params: {
|
||||
suspend_until: 5.hours.from_now,
|
||||
reason: "because I said so"
|
||||
}
|
||||
|
||||
put "/admin/users/#{user.id}/suspend.json", params: {
|
||||
suspend_until: 5.hours.from_now,
|
||||
reason: "because I said so too"
|
||||
}
|
||||
|
||||
expect(response.status).to eq(409)
|
||||
expect(response.parsed_body["message"]).to eq(
|
||||
I18n.t(
|
||||
"user.already_suspended",
|
||||
staff: admin.username,
|
||||
time_ago: FreedomPatches::Rails4.time_ago_in_words(user.suspend_record.created_at, true, scope: :'datetime.distance_in_words_verbose')
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
it "requires suspend_until and reason" do
|
||||
expect(user).not_to be_suspended
|
||||
put "/admin/users/#{user.id}/suspend.json", params: {}
|
||||
@ -749,6 +770,27 @@ RSpec.describe Admin::UsersController do
|
||||
reg_user.reload
|
||||
expect(reg_user).to be_silenced
|
||||
end
|
||||
|
||||
it "checks if user is silenced" do
|
||||
put "/admin/users/#{user.id}/silence.json", params: {
|
||||
silenced_till: 5.hours.from_now,
|
||||
reason: "because I said so"
|
||||
}
|
||||
|
||||
put "/admin/users/#{user.id}/silence.json", params: {
|
||||
silenced_till: 5.hours.from_now,
|
||||
reason: "because I said so too"
|
||||
}
|
||||
|
||||
expect(response.status).to eq(409)
|
||||
expect(response.parsed_body["message"]).to eq(
|
||||
I18n.t(
|
||||
"user.already_silenced",
|
||||
staff: admin.username,
|
||||
time_ago: FreedomPatches::Rails4.time_ago_in_words(user.silenced_record.created_at, true, scope: :'datetime.distance_in_words_verbose')
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#unsilence' do
|
||||
|
Reference in New Issue
Block a user