FIX: Incorrect query when removing a group owner.

https://meta.discourse.org/t/group-rename-and-group-owners-removal-problems/85596
This commit is contained in:
Guo Xiang Tan 2018-05-07 13:56:27 +08:00
parent b618ffb715
commit aa0d32231c
2 changed files with 14 additions and 1 deletions

View File

@ -105,7 +105,7 @@ class Admin::GroupsController < Admin::AdminController
end end
def remove_owner def remove_owner
group = Group.find_by(params.require(:id)) group = Group.find_by(id: params.require(:id))
raise Discourse::NotFound unless group raise Discourse::NotFound unless group
return can_not_modify_automatic if group.automatic return can_not_modify_automatic if group.automatic

View File

@ -51,6 +51,19 @@ RSpec.describe Admin::GroupsController do
end end
end end
describe '#remove_owner' do
it 'should work' do
group.add_owner(user)
delete "/admin/groups/#{group.id}/owners.json", params: {
user_id: user.id
}
expect(response.status).to eq(200)
expect(group.group_users.where(owner: true)).to eq([])
end
end
describe "#bulk_perform" do describe "#bulk_perform" do
let(:group) do let(:group) do
Fabricate(:group, Fabricate(:group,