Guo Xiang Tan 2017-03-25 08:20:36 +08:00
parent 80edb4cebc
commit 7c17966171
2 changed files with 18 additions and 0 deletions

View File

@ -2,4 +2,8 @@ class WebHookUserSerializer < UserSerializer
# remove staff attributes
def staff_attributes(*attrs)
end
def include_email?
scope.is_admin?
end
end

View File

@ -0,0 +1,14 @@
require 'rails_helper'
RSpec.describe WebHookUserSerializer do
let(:user) { Fabricate(:user) }
let(:admin) { Fabricate(:admin) }
subject { described_class.new(user, scope: Guardian.new(admin), root: false) }
it "should include the user's email" do
payload = subject.as_json
expect(payload[:email]).to eq(user.email)
end
end