mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
FIX: Don't raise an error if you try to assign a group that exists
This commit is contained in:
@ -37,7 +37,6 @@ describe Admin::UsersController do
|
||||
expect(UserHistory.where(action: UserHistory.actions[:check_email], acting_user_id: @user.id).count).to eq(0)
|
||||
|
||||
xhr :get, :index, show_emails: "true"
|
||||
data = ::JSON.parse(response.body)
|
||||
|
||||
expect(UserHistory.where(action: UserHistory.actions[:check_email], acting_user_id: @user.id).count).to eq(1)
|
||||
end
|
||||
@ -173,6 +172,22 @@ describe Admin::UsersController do
|
||||
end
|
||||
end
|
||||
|
||||
context '.add_group' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:group) { Fabricate(:group) }
|
||||
|
||||
it 'adds the user to the group' do
|
||||
xhr :post, :add_group, group_id: group.id, user_id: user.id
|
||||
expect(response).to be_success
|
||||
|
||||
expect(GroupUser.where(user_id: user.id, group_id: group.id).exists?).to eq(true)
|
||||
|
||||
# Doing it again doesn't raise an error
|
||||
xhr :post, :add_group, group_id: group.id, user_id: user.id
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
||||
context '.primary_group' do
|
||||
before do
|
||||
@another_user = Fabricate(:coding_horror)
|
||||
|
Reference in New Issue
Block a user