A platform for community discussion. Free, open, simple.
FEATURE: Allow add group member endpoint to skip invite emails (#29962)
Mark VanLandingham8c311dcbd5b2
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rbindex fce5dfbcef4..0349964477d 100644--- a/app/controllers/groups_controller.rb+++ b/app/controllers/groups_controller.rb@@ -413,7 +413,12 @@ class GroupsController < ApplicationControlleremails.each do |email|begin- Invite.generate(current_user, email: email, group_ids: [group.id])+ Invite.generate(+ current_user,+ email: email,+ group_ids: [group.id],+ skip_email: params[:skip_email].to_s == "true",+ )rescue RateLimiter::LimitExceeded => ereturn(render_json_error(diff --git a/spec/requests/groups_controller_spec.rb b/spec/requests/groups_controller_spec.rbindex 48de892ca45..6ce25b006c5 100644--- a/spec/requests/groups_controller_spec.rb+++ b/spec/requests/groups_controller_spec.rb@@ -1707,6 +1707,23 @@ RSpec.describe GroupsController doendend+ it "sends emails with invitations when `skip_emails` param isn't present" do+ expect_enqueued_with(job: :invite_email) do+ put "/groups/#{group.id}/members.json", params: { emails: "[email protected]" }+ expect(response.status).to eq(200)+ end+ end++ it "sends emails with invitations when `skip_emails` is present" do+ expect_not_enqueued_with(job: :invite_email) do+ put "/groups/#{group.id}/members.json?skip_email=true",+ params: {+ emails: "[email protected]",+ }+ expect(response.status).to eq(200)+ end+ end+it "displays warning when all members already exists" douser1.update!(username: "john")user2.update!(username: "alice")