Skip to content
代码片段 群组 项目
提交 d1a440e7 编辑于 作者: Serena Fang's avatar Serena Fang
浏览文件

Add tests for admin current user

上级 545cdd7a
No related branches found
No related tags found
无相关合并请求
......@@ -4,7 +4,7 @@ module API
module Entities
class UserSafe < Grape::Entity
expose :id, :username
expose :name, unless: ->(user) { user.project_bot? }
expose :name, unless: ->(user) { user.project_bot? && !options[:current_user].admin?}
end
end
end
......@@ -39,8 +39,18 @@
context 'with project bot user' do
let(:user) { create(:user, :project_bot) }
it 'does not expose project bot user name' do
expect(subject).not_to include(:name)
context 'when the requester is not an admin' do
it 'does not expose project bot user name' do
expect(subject).not_to include(:name)
end
end
context 'when the requester is an admin' do
let(:current_user) { create(:user, :admin) }
it 'exposes project bot user name' do
expect(subject).to include(:name)
end
end
end
end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册