mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FIX: Don't raise an error if you try to assign a group that exists
This commit is contained in:
parent
6b236d3c83
commit
23371b026d
2 changed files with 20 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue