2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-03-24 20:20:36 -04:00
|
|
|
RSpec.describe WebHookUserSerializer do
|
2018-01-21 18:09:26 -05:00
|
|
|
let(:user) do
|
|
|
|
user = Fabricate(:user)
|
|
|
|
SingleSignOnRecord.create!(user_id: user.id, external_id: '12345', last_payload: '')
|
|
|
|
user
|
|
|
|
end
|
2017-03-24 20:20:36 -04:00
|
|
|
|
2019-05-06 23:12:20 -04:00
|
|
|
fab!(:admin) { Fabricate(:admin) }
|
2017-03-24 20:20:36 -04:00
|
|
|
|
2018-01-21 18:09:26 -05:00
|
|
|
let :serializer do
|
|
|
|
WebHookUserSerializer.new(user, scope: Guardian.new(admin), root: false)
|
|
|
|
end
|
2017-03-24 20:20:36 -04:00
|
|
|
|
2022-12-13 19:25:19 -05:00
|
|
|
before do
|
|
|
|
SiteSetting.navigation_menu = "legacy"
|
|
|
|
SiteSetting.chat_enabled = false if defined?(::Chat)
|
|
|
|
end
|
|
|
|
|
2018-01-21 18:09:26 -05:00
|
|
|
it "should include relevant user info" do
|
|
|
|
payload = serializer.as_json
|
2017-03-24 20:20:36 -04:00
|
|
|
expect(payload[:email]).to eq(user.email)
|
2018-01-21 18:09:26 -05:00
|
|
|
expect(payload[:external_id]).to eq('12345')
|
2017-03-24 20:20:36 -04:00
|
|
|
end
|
2018-05-20 23:25:01 -04:00
|
|
|
|
|
|
|
it 'should only include the required keys' do
|
2021-07-08 03:46:21 -04:00
|
|
|
expect(serializer.as_json.keys).to contain_exactly(
|
|
|
|
:id,
|
|
|
|
:username,
|
|
|
|
:name,
|
|
|
|
:avatar_template,
|
|
|
|
:email,
|
|
|
|
:secondary_emails,
|
|
|
|
:last_posted_at,
|
|
|
|
:last_seen_at,
|
|
|
|
:created_at,
|
|
|
|
:muted,
|
|
|
|
:trust_level,
|
|
|
|
:moderator,
|
|
|
|
:admin,
|
|
|
|
:title,
|
|
|
|
:badge_count,
|
|
|
|
:time_read,
|
|
|
|
:recent_time_read,
|
|
|
|
:primary_group_id,
|
|
|
|
:primary_group_name,
|
2021-07-20 06:06:40 -04:00
|
|
|
:flair_group_id,
|
2021-07-08 03:46:21 -04:00
|
|
|
:flair_name,
|
|
|
|
:flair_url,
|
|
|
|
:flair_bg_color,
|
|
|
|
:flair_color,
|
|
|
|
:featured_topic,
|
|
|
|
:staged,
|
|
|
|
:pending_count,
|
|
|
|
:profile_view_count,
|
|
|
|
:second_factor_enabled,
|
|
|
|
:can_upload_profile_header,
|
|
|
|
:can_upload_user_card_background,
|
|
|
|
:post_count,
|
|
|
|
:locale,
|
|
|
|
:muted_category_ids,
|
|
|
|
:regular_category_ids,
|
|
|
|
:watched_tags,
|
|
|
|
:watching_first_post_tags,
|
|
|
|
:tracked_tags,
|
|
|
|
:muted_tags,
|
|
|
|
:tracked_category_ids,
|
|
|
|
:watched_category_ids,
|
|
|
|
:watched_first_post_category_ids,
|
|
|
|
:system_avatar_template,
|
|
|
|
:muted_usernames,
|
|
|
|
:ignored_usernames,
|
|
|
|
:allowed_pm_usernames,
|
|
|
|
:mailing_list_posts_per_day,
|
|
|
|
:user_notification_schedule,
|
|
|
|
:external_id,
|
|
|
|
:featured_user_badge_ids,
|
|
|
|
:invited_by,
|
|
|
|
:groups,
|
|
|
|
:user_option
|
|
|
|
)
|
2018-05-20 23:25:01 -04:00
|
|
|
end
|
2017-03-24 20:20:36 -04:00
|
|
|
end
|