From ee664acb356f8123f4f6b00b73c1e1cf0866c7fb Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 20 Oct 2022 09:40:42 +0000 Subject: Add latest changes from gitlab-org/gitlab@15-5-stable-ee --- spec/requests/users_controller_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'spec/requests/users_controller_spec.rb') diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb index 42f14392117..e78d4cc326e 100644 --- a/spec/requests/users_controller_spec.rb +++ b/spec/requests/users_controller_spec.rb @@ -828,6 +828,26 @@ RSpec.describe UsersController do end end + describe 'POST #follow' do + context 'when over followee limit' do + before do + stub_const('Users::UserFollowUser::MAX_FOLLOWEE_LIMIT', 2) + sign_in(user) + end + + it 'alerts and not follow' do + Users::UserFollowUser::MAX_FOLLOWEE_LIMIT.times { user.follow(create(:user)) } + + post user_follow_url(username: public_user.username) + expect(response).to be_redirect + + expected_message = format(_("You can't follow more than %{limit} users. To follow more users, unfollow some others."), limit: Users::UserFollowUser::MAX_FOLLOWEE_LIMIT) + expect(flash[:alert]).to eq(expected_message) + expect(user).not_to be_following(public_user) + end + end + end + context 'token authentication' do it_behaves_like 'authenticates sessionless user for the request spec', 'show atom', public_resource: true do let(:url) { user_url(user, format: :atom) } -- cgit v1.2.1