mirror of
https://github.com/discourse/discourse.git
synced 2025-04-03 05:39:41 +08:00
FIX: Refresh automatic groups after inviting moderators.
This commit is contained in:
parent
04abf18194
commit
07b80d491b
@ -223,6 +223,8 @@ class InvitesController < ApplicationController
|
|||||||
def post_process_invite(user)
|
def post_process_invite(user)
|
||||||
user.enqueue_welcome_message('welcome_invite') if user.send_welcome_message
|
user.enqueue_welcome_message('welcome_invite') if user.send_welcome_message
|
||||||
|
|
||||||
|
Group.refresh_automatic_groups!(:admins, :moderators, :staff) if user.staff?
|
||||||
|
|
||||||
if user.has_password?
|
if user.has_password?
|
||||||
send_activation_email(user) unless user.active
|
send_activation_email(user) unless user.active
|
||||||
elsif !SiteSetting.enable_sso && SiteSetting.enable_local_logins
|
elsif !SiteSetting.enable_sso && SiteSetting.enable_local_logins
|
||||||
|
@ -312,11 +312,20 @@ describe InvitesController do
|
|||||||
expect(Jobs::SendSystemMessage.jobs.size).to eq(1)
|
expect(Jobs::SendSystemMessage.jobs.size).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'refreshes automatic groups if staff' do
|
||||||
|
topic.user.grant_admin!
|
||||||
|
invite.update!(moderator: true)
|
||||||
|
|
||||||
|
put "/invites/show/#{invite.invite_key}.json"
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
|
expect(invite.reload.user.groups.pluck(:name)).to contain_exactly("moderators", "staff")
|
||||||
|
end
|
||||||
|
|
||||||
context "without password" do
|
context "without password" do
|
||||||
it "sends password reset email" do
|
it "sends password reset email" do
|
||||||
put "/invites/show/#{invite.invite_key}.json"
|
put "/invites/show/#{invite.invite_key}.json"
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
expect(JSON.parse(response.body)["success"]).to eq(true)
|
|
||||||
|
|
||||||
expect(Jobs::InvitePasswordInstructionsEmail.jobs.size).to eq(1)
|
expect(Jobs::InvitePasswordInstructionsEmail.jobs.size).to eq(1)
|
||||||
expect(Jobs::CriticalUserEmail.jobs.size).to eq(0)
|
expect(Jobs::CriticalUserEmail.jobs.size).to eq(0)
|
||||||
@ -327,7 +336,6 @@ describe InvitesController do
|
|||||||
SiteSetting.enable_sso = true
|
SiteSetting.enable_sso = true
|
||||||
put "/invites/show/#{invite.invite_key}.json"
|
put "/invites/show/#{invite.invite_key}.json"
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
expect(JSON.parse(response.body)["success"]).to eq(true)
|
|
||||||
|
|
||||||
expect(Jobs::InvitePasswordInstructionsEmail.jobs.size).to eq(0)
|
expect(Jobs::InvitePasswordInstructionsEmail.jobs.size).to eq(0)
|
||||||
expect(Jobs::CriticalUserEmail.jobs.size).to eq(0)
|
expect(Jobs::CriticalUserEmail.jobs.size).to eq(0)
|
||||||
@ -337,7 +345,6 @@ describe InvitesController do
|
|||||||
SiteSetting.enable_local_logins = false
|
SiteSetting.enable_local_logins = false
|
||||||
put "/invites/show/#{invite.invite_key}.json"
|
put "/invites/show/#{invite.invite_key}.json"
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
expect(JSON.parse(response.body)["success"]).to eq(true)
|
|
||||||
|
|
||||||
expect(Jobs::InvitePasswordInstructionsEmail.jobs.size).to eq(0)
|
expect(Jobs::InvitePasswordInstructionsEmail.jobs.size).to eq(0)
|
||||||
expect(Jobs::CriticalUserEmail.jobs.size).to eq(0)
|
expect(Jobs::CriticalUserEmail.jobs.size).to eq(0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user