mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 10:29:35 +08:00
690f17bcbe
* FEATURE: Allow List for PMs This feature adds a new user setting that is disabled by default that allows them to specify a list of users that are allowed to send them private messages. This way they don't have to maintain a large list of users they don't want to here from and instead just list the people they know they do want. Staff will still always be able to send messages to the user. * Update PR based on feedback
36 lines
1.0 KiB
Ruby
36 lines
1.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe WebHookUserSerializer do
|
|
let(:user) do
|
|
user = Fabricate(:user)
|
|
SingleSignOnRecord.create!(user_id: user.id, external_id: '12345', last_payload: '')
|
|
user
|
|
end
|
|
|
|
fab!(:admin) { Fabricate(:admin) }
|
|
|
|
let :serializer do
|
|
WebHookUserSerializer.new(user, scope: Guardian.new(admin), root: false)
|
|
end
|
|
|
|
it "should include relevant user info" do
|
|
payload = serializer.as_json
|
|
expect(payload[:email]).to eq(user.email)
|
|
expect(payload[:external_id]).to eq('12345')
|
|
end
|
|
|
|
it 'should only include the required keys' do
|
|
count = serializer.as_json.keys.count
|
|
difference = count - 47
|
|
|
|
expect(difference).to eq(0), lambda {
|
|
message = (difference < 0 ?
|
|
"#{difference * -1} key(s) have been removed from this serializer." :
|
|
"#{difference} key(s) have been added to this serializer.") +
|
|
"\nPlease verify if those key(s) are required as part of the web hook's payload."
|
|
}
|
|
end
|
|
end
|