REFACTOR: Move option to return emails into the serializer

This makes more sense than having the guardian take an accessor.
The logic belongs in the Serializer, where the JSON is calculated.

Also removed some of the DRYness in the spec. It's fewer lines
and made it easier to test the option on the serializer.
This commit is contained in:
Robin Ward
2019-01-11 11:10:02 -05:00
parent f94c0283b2
commit dbe42068a2
4 changed files with 40 additions and 77 deletions

View File

@@ -32,12 +32,13 @@ class Admin::UsersController < Admin::AdminController
def index
users = ::AdminUserIndexQuery.new(params).find_users
opts = {}
if params[:show_emails] == "true"
guardian.can_see_emails = true
StaffActionLogger.new(current_user).log_show_emails(users)
opts[:emails_desired] = true
end
render_serialized(users, AdminUserListSerializer)
render_serialized(users, AdminUserListSerializer, opts)
end
def show