2019-04-30 08:27:42 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-28 10:27:38 +08:00
|
|
|
RSpec.describe ReviewableUserSerializer do
|
2019-04-04 04:41:04 +08:00
|
|
|
let(:user) { Fabricate(:user) }
|
2019-01-04 01:03:01 +08:00
|
|
|
let(:admin) { Fabricate(:admin) }
|
|
|
|
|
|
|
|
it "includes the user fields for review" do
|
2019-04-11 23:11:35 +08:00
|
|
|
SiteSetting.must_approve_users = true
|
2019-04-04 04:41:04 +08:00
|
|
|
Jobs::CreateUserReviewable.new.execute(user_id: user.id)
|
|
|
|
reviewable = Reviewable.find_by(target: user)
|
|
|
|
|
2019-01-04 01:03:01 +08:00
|
|
|
json = ReviewableUserSerializer.new(reviewable, scope: Guardian.new(admin), root: nil).as_json
|
|
|
|
expect(json[:user_id]).to eq(reviewable.target_id)
|
2019-04-04 04:41:04 +08: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-02 02:28:57 +08:00
|
|
|
expect(json[:topic_url]).to be_blank
|
2019-01-04 01:03:01 +08:00
|
|
|
end
|
|
|
|
end
|