mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
Remove admin group management pages.
This commit is contained in:
@ -21,7 +21,7 @@ RSpec.describe Admin::GroupsController do
|
||||
}
|
||||
}
|
||||
|
||||
expect(response).to be_success
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
group = Group.last
|
||||
|
||||
@ -50,4 +50,68 @@ RSpec.describe Admin::GroupsController do
|
||||
.to contain_exactly(user, admin)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#bulk_perform" do
|
||||
let(:group) do
|
||||
Fabricate(:group,
|
||||
name: "test",
|
||||
primary_group: true,
|
||||
title: 'WAT',
|
||||
grant_trust_level: 3
|
||||
)
|
||||
end
|
||||
|
||||
let(:user) { Fabricate(:user, trust_level: 2) }
|
||||
let(:user2) { Fabricate(:user, trust_level: 4) }
|
||||
|
||||
it "can assign users to a group by email or username" do
|
||||
put "/admin/groups/bulk.json", params: {
|
||||
group_id: group.id, users: [user.username.upcase, user2.email, 'doesnt_exist']
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
user.reload
|
||||
expect(user.primary_group).to eq(group)
|
||||
expect(user.title).to eq("WAT")
|
||||
expect(user.trust_level).to eq(3)
|
||||
|
||||
user2.reload
|
||||
expect(user2.primary_group).to eq(group)
|
||||
expect(user2.title).to eq("WAT")
|
||||
expect(user2.trust_level).to eq(4)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
expect(json['message']).to eq("2 users have been added to the group.")
|
||||
expect(json['users_not_added'][0]).to eq("doesnt_exist")
|
||||
end
|
||||
end
|
||||
|
||||
context "#destroy" do
|
||||
it 'should return the right response for an invalid group_id' do
|
||||
delete "/admin/groups/123.json"
|
||||
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
|
||||
describe 'when group is automatic' do
|
||||
it "returns the right response" do
|
||||
group.update!(automatic: true)
|
||||
|
||||
delete "/admin/groups/#{group.id}.json"
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
expect(Group.find(group.id)).to eq(group)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'for a non automatic group' do
|
||||
it "returns the right response" do
|
||||
delete "/admin/groups/#{group.id}.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(Group.find_by(id: group.id)).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user