Commit 92942922 authored by Gary Holtz's avatar Gary Holtz Committed by Mark Chao

Support "view_diffs_file_by_file" param in the Users create and update API

parent 088cb4ea
......@@ -83,7 +83,8 @@ module Users
:location,
:public_email,
:user_type,
:note
:note,
:view_diffs_file_by_file
]
end
......
---
title: Support "view_diffs_file_by_file" param in the Users create and update API
merge_request: 54595
author:
type: added
......@@ -433,6 +433,7 @@ Parameters:
| `theme_id` | No | The GitLab theme for the user (see [the user preference docs](../user/profile/preferences.md#navigation-theme) for more information) |
| `twitter` | No | Twitter account |
| `username` | Yes | Username |
| `view_diffs_file_by_file` | No | Flag indicating the user sees only one file diff per page |
| `website_url` | No | Website URL |
## User modification
......@@ -474,6 +475,7 @@ Parameters:
| `theme_id` | No | The GitLab theme for the user (see [the user preference docs](../user/profile/preferences.md#navigation-theme) for more information) |
| `twitter` | No | Twitter account |
| `username` | No | Username |
| `view_diffs_file_by_file` | No | Flag indicating the user sees only one file diff per page |
| `website_url` | No | Website URL |
On password update, the user is forced to change it upon next login.
......
......@@ -58,6 +58,7 @@ module API
optional :color_scheme_id, type: Integer, desc: 'The color scheme for the file viewer'
optional :private_profile, type: Boolean, desc: 'Flag indicating the user has a private profile'
optional :note, type: String, desc: 'Admin note for this user'
optional :view_diffs_file_by_file, type: Boolean, desc: 'Flag indicating the user sees only one file diff per page'
all_or_none_of :extern_uid, :provider
use :optional_params_ee
......
......@@ -940,6 +940,18 @@ RSpec.describe API::Users do
expect(new_user.private_profile?).to eq(true)
end
it "creates user with view_diffs_file_by_file" do
post api('/users', admin), params: attributes_for(:user, view_diffs_file_by_file: true)
expect(response).to have_gitlab_http_status(:created)
user_id = json_response['id']
new_user = User.find(user_id)
expect(new_user).not_to eq(nil)
expect(new_user.user_preference.view_diffs_file_by_file?).to eq(true)
end
it "does not create user with invalid email" do
post api('/users', admin),
params: {
......@@ -1254,6 +1266,13 @@ RSpec.describe API::Users do
expect(user.reload.private_profile).to eq(true)
end
it "updates viewing diffs file by file" do
put api("/users/#{user.id}", admin), params: { view_diffs_file_by_file: true }
expect(response).to have_gitlab_http_status(:ok)
expect(user.reload.user_preference.view_diffs_file_by_file?).to eq(true)
end
it "updates private profile to false when nil is given" do
user.update!(private_profile: true)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment