Commit f905708f authored by Robert Speicher's avatar Robert Speicher

Use UserSerializer instead of `User.to_json`

parent 750b2b3b
......@@ -8,7 +8,7 @@ class AutocompleteController < ApplicationController
def users
@users = AutocompleteUsersFinder.new(params: params, current_user: current_user, project: @project, group: @group).execute
render json: @users, only: [:name, :username, :id], methods: [:avatar_url]
render json: UserSerializer.new.represent(@users)
end
def project_groups
......@@ -17,7 +17,7 @@ class AutocompleteController < ApplicationController
def user
@user = User.find(params[:id])
render json: @user, only: [:name, :username, :id], methods: [:avatar_url]
render json: UserSerializer.new.represent(@user)
end
def projects
......
......@@ -37,7 +37,7 @@ module FormHelper
multi_select: true,
'input-meta': 'name',
'always-show-selectbox': true,
current_user_info: current_user.to_json(only: [:id, :name])
current_user_info: UserSerializer.new.represent(current_user)
}
}
end
......
......@@ -365,7 +365,7 @@ module IssuablesHelper
moveIssueEndpoint: move_namespace_project_issue_path(namespace_id: issuable.project.namespace.to_param, project_id: issuable.project, id: issuable),
projectsAutocompleteEndpoint: autocomplete_projects_path(project_id: @project.id),
editable: can_edit_issuable,
currentUser: current_user.as_json(only: [:username, :id, :name], methods: :avatar_url),
currentUser: UserSerializer.new.represent(current_user),
rootPath: root_path,
fullPath: @project.full_path,
weightOptions: Issue.weight_options,
......
......@@ -149,7 +149,7 @@ module SearchHelper
id: "filtered-search-#{type}",
placeholder: 'Search or filter results...',
data: {
'username-params' => @users.to_json(only: [:id, :username])
'username-params' => UserSerializer.new.represent(@users)
},
autocomplete: 'off'
}
......
%board-sidebar{ "inline-template" => true,
":current-user" => "#{current_user ? current_user.to_json(only: [:username, :id, :name], methods: [:avatar_url]) : {}}" }
%board-sidebar{ "inline-template" => true, ":current-user" => (UserSerializer.new.represent(current_user) || {}).to_json }
%transition{ name: "boards-sidebar-slide" }
%aside.right-sidebar.right-sidebar-expanded.issue-boards-sidebar{ "v-show" => "showSidebar" }
.issuable-sidebar
......
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