Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests/api/users_spec.rb')
-rw-r--r--spec/requests/api/users_spec.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index 96e23337411..1b0a27e78e3 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -165,6 +165,7 @@ RSpec.describe API::Users do
expect(json_response.first).not_to have_key('note')
expect(json_response.first).not_to have_key('namespace_id')
+ expect(json_response.first).not_to have_key('created_by')
end
end
@@ -175,6 +176,7 @@ RSpec.describe API::Users do
expect(json_response.first).not_to have_key('note')
expect(json_response.first).not_to have_key('namespace_id')
+ expect(json_response.first).not_to have_key('created_by')
end
end
@@ -186,6 +188,26 @@ RSpec.describe API::Users do
expect(json_response.first).to have_key('note')
expect(json_response.first['note']).to eq '2018-11-05 | 2FA removed | user requested | www.gitlab.com'
end
+
+ context 'with `created_by` details' do
+ it 'has created_by as nil with a self-registered account' do
+ get api("/users", admin), params: { username: user.username }
+
+ expect(response).to have_gitlab_http_status(:success)
+ expect(json_response.first).to have_key('created_by')
+ expect(json_response.first['created_by']).to eq(nil)
+ end
+
+ it 'is created_by a user and has those details' do
+ created = create(:user, created_by_id: user.id)
+
+ get api("/users", admin), params: { username: created.username }
+
+ expect(response).to have_gitlab_http_status(:success)
+ expect(json_response.first['created_by'].symbolize_keys)
+ .to eq(API::Entities::UserBasic.new(user).as_json)
+ end
+ end
end
context 'N+1 queries' do
@@ -940,6 +962,17 @@ RSpec.describe API::Users do
expect(user.followees).to contain_exactly(followee)
expect(response).to have_gitlab_http_status(:created)
end
+
+ it 'alerts and not follow when over followee limit' do
+ stub_const('Users::UserFollowUser::MAX_FOLLOWEE_LIMIT', 2)
+ Users::UserFollowUser::MAX_FOLLOWEE_LIMIT.times { user.follow(create(:user)) }
+
+ post api("/users/#{followee.id}/follow", user)
+ expect(response).to have_gitlab_http_status(:bad_request)
+ 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(json_response['message']).to eq(expected_message)
+ expect(user.following?(followee)).to be_falsey
+ end
end
context 'on a followed user' do