From 558914b98672e7800aba94d7095b1f71fb14f658 Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Tue, 27 Mar 2018 11:14:06 +0200 Subject: [PATCH] Fix random spec errors --- app/controllers/groups_controller.rb | 2 +- spec/requests/groups_controller_spec.rb | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index a30a34b8f15..1cf32c8ead1 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -253,7 +253,7 @@ class GroupsController < ApplicationController if (usernames = group.users.where(id: users.pluck(:id)).pluck(:username)).present? render_json_error(I18n.t( "groups.errors.member_already_exist", - username: usernames.join(", "), + username: usernames.sort.join(", "), count: usernames.size )) else diff --git a/spec/requests/groups_controller_spec.rb b/spec/requests/groups_controller_spec.rb index 9532b927772..5e47f4d95c5 100644 --- a/spec/requests/groups_controller_spec.rb +++ b/spec/requests/groups_controller_spec.rb @@ -589,7 +589,8 @@ describe GroupsController do end 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) } expect do @@ -601,7 +602,7 @@ describe GroupsController do expect(JSON.parse(response.body)["errors"]).to include(I18n.t( "groups.errors.member_already_exist", - username: "#{user2.username}, #{user3.username}", + username: "alice, bob", count: 2 )) end