diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-07 03:09:12 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-07 03:09:12 +0300 |
commit | 6168721025dd8e98caeb2bf6844273e6690eaf69 (patch) | |
tree | 8c4fb20d793669e488a739bc9951dab8b363eed4 /spec/requests/api/users_spec.rb | |
parent | a89cb5cbdd832d4d9e80517973aceda6bc0a3856 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/api/users_spec.rb')
-rw-r--r-- | spec/requests/api/users_spec.rb | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index f6ff2020c79..aa8dd021707 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -461,7 +461,7 @@ describe API::Users do end it "creates user with optional attributes" do - optional_attributes = { confirm: true } + optional_attributes = { confirm: true, theme_id: 2, color_scheme_id: 4 } attributes = attributes_for(:user).merge(optional_attributes) post api('/users', admin), params: attributes @@ -576,6 +576,15 @@ describe API::Users do expect(response).to have_gitlab_http_status(400) end + it "doesn't create user with invalid optional attributes" do + optional_attributes = { theme_id: 50, color_scheme_id: 50 } + attributes = attributes_for(:user).merge(optional_attributes) + + post api('/users', admin), params: attributes + + expect(response).to have_gitlab_http_status(400) + end + it 'returns 400 error if user does not validate' do post api('/users', admin), params: { @@ -824,6 +833,34 @@ describe API::Users do expect(user.reload.email).not_to eq('invalid email') end + it "updates theme id" do + put api("/users/#{user.id}", admin), params: { theme_id: 5 } + + expect(response).to have_gitlab_http_status(200) + expect(user.reload.theme_id).to eq(5) + end + + it "does not update invalid theme id" do + put api("/users/#{user.id}", admin), params: { theme_id: 50 } + + expect(response).to have_gitlab_http_status(400) + expect(user.reload.theme_id).not_to eq(50) + end + + it "updates color scheme id" do + put api("/users/#{user.id}", admin), params: { color_scheme_id: 5 } + + expect(response).to have_gitlab_http_status(200) + expect(user.reload.color_scheme_id).to eq(5) + end + + it "does not update invalid color scheme id" do + put api("/users/#{user.id}", admin), params: { color_scheme_id: 50 } + + expect(response).to have_gitlab_http_status(400) + expect(user.reload.color_scheme_id).not_to eq(50) + end + context 'when the current user is not an admin' do it "is not available" do expect do |