2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-01-03 12:03:01 -05:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe ReviewableUserSerializer do
|
|
|
|
|
2019-04-03 16:41:04 -04:00
|
|
|
let(:user) { Fabricate(:user) }
|
2019-01-03 12:03:01 -05:00
|
|
|
let(:admin) { Fabricate(:admin) }
|
|
|
|
|
|
|
|
it "includes the user fields for review" do
|
2019-04-11 11:11:35 -04:00
|
|
|
SiteSetting.must_approve_users = true
|
2019-04-03 16:41:04 -04:00
|
|
|
Jobs::CreateUserReviewable.new.execute(user_id: user.id)
|
|
|
|
reviewable = Reviewable.find_by(target: user)
|
|
|
|
|
2019-01-03 12:03:01 -05:00
|
|
|
json = ReviewableUserSerializer.new(reviewable, scope: Guardian.new(admin), root: nil).as_json
|
|
|
|
expect(json[:user_id]).to eq(reviewable.target_id)
|
2019-04-03 16:41:04 -04:00
|
|
|
expect(json[:payload]['username']).to eq(user.username)
|
|
|
|
expect(json[:payload]['email']).to eq(user.email)
|
|
|
|
expect(json[:payload]['name']).to eq(user.name)
|
2019-04-01 14:28:57 -04:00
|
|
|
expect(json[:topic_url]).to be_blank
|
2019-01-03 12:03:01 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|