Fix random spec errors

This commit is contained in:
Gerhard Schlager 2018-03-27 11:14:06 +02:00
parent 31dea5d5fc
commit 558914b986
2 changed files with 4 additions and 3 deletions

View File

@ -253,7 +253,7 @@ class GroupsController < ApplicationController
if (usernames = group.users.where(id: users.pluck(:id)).pluck(:username)).present? if (usernames = group.users.where(id: users.pluck(:id)).pluck(:username)).present?
render_json_error(I18n.t( render_json_error(I18n.t(
"groups.errors.member_already_exist", "groups.errors.member_already_exist",
username: usernames.join(", "), username: usernames.sort.join(", "),
count: usernames.size count: usernames.size
)) ))
else else

View File

@ -589,7 +589,8 @@ describe GroupsController do
end end
it 'fails when multiple member already exists' do it 'fails when multiple member already exists' do
user3 = Fabricate(:user) user2.update!(username: 'alice')
user3 = Fabricate(:user, username: 'bob')
[user2, user3].each { |user| group.add(user) } [user2, user3].each { |user| group.add(user) }
expect do expect do
@ -601,7 +602,7 @@ describe GroupsController do
expect(JSON.parse(response.body)["errors"]).to include(I18n.t( expect(JSON.parse(response.body)["errors"]).to include(I18n.t(
"groups.errors.member_already_exist", "groups.errors.member_already_exist",
username: "#{user2.username}, #{user3.username}", username: "alice, bob",
count: 2 count: 2
)) ))
end end