Commit 5880d259 authored by Sean Arnold's avatar Sean Arnold

Add OncallScheduleEntity to users in Admin helper

parent e2f2c941
...@@ -13,7 +13,7 @@ class Admin::UsersController < Admin::ApplicationController ...@@ -13,7 +13,7 @@ class Admin::UsersController < Admin::ApplicationController
def index def index
@users = User.filter_items(params[:filter]).order_name_asc @users = User.filter_items(params[:filter]).order_name_asc
@users = @users.search_with_secondary_emails(params[:search_query]) if params[:search_query].present? @users = @users.search_with_secondary_emails(params[:search_query]) if params[:search_query].present?
@users = @users.includes(:authorized_projects) # rubocop: disable CodeReuse/ActiveRecord @users = users_with_included_associations(@users)
@users = @users.sort_by_attribute(@sort = params[:sort]) @users = @users.sort_by_attribute(@sort = params[:sort])
@users = @users.page(params[:page]) @users = @users.page(params[:page])
...@@ -228,6 +228,10 @@ class Admin::UsersController < Admin::ApplicationController ...@@ -228,6 +228,10 @@ class Admin::UsersController < Admin::ApplicationController
protected protected
def users_with_included_associations(users)
users.includes(:authorized_projects) # rubocop: disable CodeReuse/ActiveRecord
end
def admin_making_changes_for_another_user? def admin_making_changes_for_another_user?
user != current_user user != current_user
end end
......
...@@ -30,3 +30,5 @@ module Admin ...@@ -30,3 +30,5 @@ module Admin
end end
end end
end end
Admin::UserEntity.prepend_if_ee('EE::Admin::UserEntity')
...@@ -19,6 +19,11 @@ module EE ...@@ -19,6 +19,11 @@ module EE
private private
override :users_with_included_associations
def users_with_included_associations(users)
super.includes(:oncall_schedules) # rubocop: disable CodeReuse/ActiveRecord
end
override :log_impersonation_event override :log_impersonation_event
def log_impersonation_event def log_impersonation_event
super super
......
# frozen_string_literal: true
module EE
module Admin
module UserEntity
extend ActiveSupport::Concern
prepended do
expose :oncall_schedules, with: ::IncidentManagement::OncallScheduleEntity
def oncall_schedules
object.oncall_schedules.uniq
end
end
end
end
end
# frozen_string_literal: true
require "spec_helper"
RSpec.describe Admin::UserEntity do
let_it_be(:user) { build_stubbed(:user) }
let(:request) { double('request') }
let(:entity) do
described_class.new(user, request: request)
end
describe '#as_json' do
subject { entity.as_json&.keys }
it 'exposes correct attributes' do
is_expected.to include(:oncall_schedules)
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