mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 02:11:08 -06:00
FIX: Write to group logs when a user is added to group by invite (#18841)
This commit is contained in:
parent
2e984f2eca
commit
391a456443
@ -209,6 +209,7 @@ class InviteRedeemer
|
||||
group = Group.find_by(id: id)
|
||||
if guardian.can_edit_group?(group)
|
||||
invited_user.group_users.create!(group_id: group.id)
|
||||
GroupActionLogger.new(invite.invited_by, group).log_add_user_to_group(invited_user)
|
||||
DiscourseEvent.trigger(:user_added_to_group, invited_user, group, automatic: false)
|
||||
end
|
||||
end
|
||||
|
@ -216,6 +216,30 @@ RSpec.describe InviteRedeemer do
|
||||
expect(user.trust_level).to eq(2)
|
||||
end
|
||||
|
||||
it "adds an entry to the group logs when the invited user is added to a group" do
|
||||
group = Fabricate(:group)
|
||||
InvitedGroup.create(group_id: group.id, invite_id: invite.id)
|
||||
group.add_owner(invite.invited_by)
|
||||
|
||||
GroupHistory.destroy_all
|
||||
|
||||
user = InviteRedeemer.new(
|
||||
invite: invite,
|
||||
email: invite.email,
|
||||
username: username,
|
||||
name: name,
|
||||
password: password
|
||||
).redeem
|
||||
|
||||
expect(group.reload.usernames.split(",")).to include(user.username)
|
||||
expect(GroupHistory.exists?(
|
||||
target_user_id: user.id,
|
||||
acting_user: invite.invited_by.id,
|
||||
group_id: group.id,
|
||||
action: GroupHistory.actions[:add_user_to_group]
|
||||
)).to eq(true)
|
||||
end
|
||||
|
||||
it "only allows one user to be created per invite" do
|
||||
user = invite_redeemer.redeem
|
||||
invite.reload
|
||||
|
Loading…
Reference in New Issue
Block a user