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:
| `twitter` | No | Twitter account |
| `username` | Yes | Username |
| `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 |
## User modification
......
......@@ -3,7 +3,7 @@
module API
module Entities
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
......@@ -1025,7 +1025,9 @@ module API
detail 'This feature was introduced in GitLab 13.10.'
end
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
put "preferences", feature_category: :users do
authenticate!
......
......@@ -8,11 +8,19 @@ RSpec.describe API::Users do
describe 'PUT /user/preferences/' do
context "with correct attributes and a logged in user" 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(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
......
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