Commit 4cb3eace authored by James Fargher's avatar James Fargher

Merge branch '329577-sync-show-whitespace-changes-in-diffs-user-preference' into 'master'

Add `show whitespace changes in diffs` attribute to user preference API

See merge request gitlab-org/gitlab!62245
parents 145d086c 896b2d6e
...@@ -453,6 +453,7 @@ Parameters: ...@@ -453,6 +453,7 @@ Parameters:
| `twitter` | No | Twitter account | | `twitter` | No | Twitter account |
| `username` | Yes | Username | | `username` | Yes | Username |
| `view_diffs_file_by_file` | No | Flag indicating the user sees only one file diff per page | | `view_diffs_file_by_file` | No | Flag indicating the user sees only one file diff per page |
| `show_whitespace_in_diffs` | No | Flag indicating the user sees whitespace changes in diffs
| `website_url` | No | Website URL | | `website_url` | No | Website URL |
## User modification ## User modification
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module API module API
module Entities module Entities
class UserPreferences < Grape::Entity class UserPreferences < Grape::Entity
expose :id, :user_id, :view_diffs_file_by_file expose :id, :user_id, :view_diffs_file_by_file, :show_whitespace_in_diffs
end end
end end
end end
...@@ -1025,7 +1025,9 @@ module API ...@@ -1025,7 +1025,9 @@ module API
detail 'This feature was introduced in GitLab 13.10.' detail 'This feature was introduced in GitLab 13.10.'
end end
params do params do
requires :view_diffs_file_by_file, type: Boolean, desc: 'Flag indicating the user sees only one file diff per page' optional :view_diffs_file_by_file, type: Boolean, desc: 'Flag indicating the user sees only one file diff per page'
optional :show_whitespace_in_diffs, type: Boolean, desc: 'Flag indicating the user sees whitespace changes in diffs'
at_least_one_of :view_diffs_file_by_file, :show_whitespace_in_diffs
end end
put "preferences", feature_category: :users do put "preferences", feature_category: :users do
authenticate! authenticate!
......
...@@ -8,11 +8,19 @@ RSpec.describe API::Users do ...@@ -8,11 +8,19 @@ RSpec.describe API::Users do
describe 'PUT /user/preferences/' do describe 'PUT /user/preferences/' do
context "with correct attributes and a logged in user" do context "with correct attributes and a logged in user" do
it 'returns a success status and the value has been changed' do it 'returns a success status and the value has been changed' do
put api("/user/preferences", user), params: { view_diffs_file_by_file: true } put api("/user/preferences", user), params: {
view_diffs_file_by_file: true,
show_whitespace_in_diffs: true
}
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['view_diffs_file_by_file']).to eq(true) expect(json_response['view_diffs_file_by_file']).to eq(true)
expect(user.reload.view_diffs_file_by_file).to be_truthy expect(json_response['show_whitespace_in_diffs']).to eq(true)
user.reload
expect(user.view_diffs_file_by_file).to be_truthy
expect(user.show_whitespace_in_diffs).to be_truthy
end end
end end
......
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