mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 03:10:46 -06:00
FIX: bug when revoking badge as title (#8616)
When user revokes badge as title, UserHistory item is created. However, that object is not accepting revoke_reson parameter.
This commit is contained in:
parent
63323bd7a8
commit
ac626a0dc3
@ -215,12 +215,13 @@ class UsersController < ApplicationController
|
||||
user.save!
|
||||
|
||||
log_params = {
|
||||
revoke_reason: 'user title was same as revoked badge name or custom badge name',
|
||||
previous_value: previous_title
|
||||
}
|
||||
|
||||
if current_user.staff? && current_user != user
|
||||
StaffActionLogger.new(current_user).log_title_revoke(user, log_params)
|
||||
StaffActionLogger
|
||||
.new(current_user)
|
||||
.log_title_revoke(user, log_params.merge(revoke_reason: 'user title was same as revoked badge name or custom badge name'))
|
||||
else
|
||||
UserHistory.create!(log_params.merge(target_user_id: user.id, action: UserHistory.actions[:revoke_title]))
|
||||
end
|
||||
|
@ -1943,6 +1943,14 @@ describe UsersController do
|
||||
expect(user.user_profile.granted_title_badge_id).to eq(nil)
|
||||
end
|
||||
|
||||
it "is not raising an erroring when user revokes title" do
|
||||
sign_in(user)
|
||||
badge.update allow_title: true
|
||||
put "/u/#{user.username}/preferences/badge_title.json", params: { user_badge_id: user_badge.id }
|
||||
put "/u/#{user.username}/preferences/badge_title.json", params: { user_badge_id: 0 }
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
context "with overrided name" do
|
||||
fab!(:badge) { Fabricate(:badge, name: 'Demogorgon', allow_title: true) }
|
||||
let(:user_badge) { BadgeGranter.grant(badge, user) }
|
||||
|
Loading…
Reference in New Issue
Block a user