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
|
|
|
|
2023-11-09 17:47:59 -05:00
|
|
|
fab!(: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
|
|
|
|
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(
|
2024-07-04 13:27:26 -04:00
|
|
|
:admin,
|
|
|
|
:allowed_pm_usernames,
|
2021-07-08 03:46:21 -04:00
|
|
|
:avatar_template,
|
2024-07-04 13:27:26 -04:00
|
|
|
:badge_count,
|
|
|
|
:can_ignore_users,
|
|
|
|
:can_mute_users,
|
|
|
|
:can_upload_profile_header,
|
|
|
|
:can_upload_user_card_background,
|
|
|
|
:created_at,
|
2021-07-08 03:46:21 -04:00
|
|
|
:email,
|
2024-07-04 13:27:26 -04:00
|
|
|
:external_id,
|
|
|
|
:featured_topic,
|
|
|
|
:featured_user_badge_ids,
|
|
|
|
:flair_bg_color,
|
|
|
|
:flair_color,
|
|
|
|
:flair_group_id,
|
|
|
|
:flair_name,
|
|
|
|
:flair_url,
|
|
|
|
:groups,
|
|
|
|
:id,
|
|
|
|
:ignored_usernames,
|
|
|
|
:invited_by,
|
2021-07-08 03:46:21 -04:00
|
|
|
:last_posted_at,
|
|
|
|
:last_seen_at,
|
2024-07-04 13:27:26 -04:00
|
|
|
:locale,
|
|
|
|
:mailing_list_posts_per_day,
|
2021-07-08 03:46:21 -04:00
|
|
|
:moderator,
|
2024-07-04 13:27:26 -04:00
|
|
|
:muted_category_ids,
|
|
|
|
:muted_tags,
|
|
|
|
:muted_usernames,
|
|
|
|
:muted,
|
|
|
|
:name,
|
|
|
|
:pending_count,
|
|
|
|
:post_count,
|
2021-07-08 03:46:21 -04:00
|
|
|
:primary_group_id,
|
|
|
|
:primary_group_name,
|
|
|
|
:profile_view_count,
|
2024-07-04 13:27:26 -04:00
|
|
|
:recent_time_read,
|
2021-07-08 03:46:21 -04:00
|
|
|
:regular_category_ids,
|
2024-07-04 13:27:26 -04:00
|
|
|
:second_factor_enabled,
|
|
|
|
:secondary_emails,
|
|
|
|
:staged,
|
2021-07-08 03:46:21 -04:00
|
|
|
:system_avatar_template,
|
2024-07-04 13:27:26 -04:00
|
|
|
:time_read,
|
|
|
|
:title,
|
|
|
|
:tracked_category_ids,
|
|
|
|
:tracked_tags,
|
|
|
|
:trust_level,
|
2021-07-08 03:46:21 -04:00
|
|
|
:user_notification_schedule,
|
|
|
|
:user_option,
|
2024-07-04 13:27:26 -04:00
|
|
|
:username,
|
|
|
|
:watched_category_ids,
|
|
|
|
:watched_first_post_category_ids,
|
|
|
|
:watched_tags,
|
|
|
|
:watching_first_post_tags,
|
2021-07-08 03:46:21 -04:00
|
|
|
)
|
2018-05-20 23:25:01 -04:00
|
|
|
end
|
2017-03-24 20:20:36 -04:00
|
|
|
end
|