Remove user from a group by user email

This commit is contained in:
Ming HU 2016-10-18 17:10:47 +08:00
parent 973a7c9d3a
commit dffd8baa91
2 changed files with 9 additions and 0 deletions

View File

@ -128,6 +128,8 @@ class GroupsController < ApplicationController
user = User.find(params[:user_id])
elsif params[:username].present?
user = User.find_by_username(params[:username])
elsif params[:user_email].present?
user = User.find_by_email(params[:user_email])
else
raise Discourse::InvalidParameters.new('user_id or username must be present')
end

View File

@ -224,6 +224,13 @@ describe GroupsController do
user.reload
expect(user.primary_group_id).to eq(nil)
end
it "removes by user_email" do
xhr :delete, :remove_member, id: group.id, user_email: user.email
expect(response).to be_success
group.reload
expect(group.users.count).to eq(0)
end
end
end