2021-01-14 13:10:59 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe MemberUserEntity do
|
2022-03-22 11:07:25 -04:00
|
|
|
let_it_be(:user) { create(:user, last_activity_on: Date.today) }
|
2021-01-14 13:10:59 -05:00
|
|
|
let_it_be(:emoji) { 'slight_smile' }
|
|
|
|
let_it_be(:user_status) { create(:user_status, user: user, emoji: emoji) }
|
2021-04-14 11:09:04 -04:00
|
|
|
|
2021-01-14 13:10:59 -05:00
|
|
|
let(:entity) { described_class.new(user) }
|
|
|
|
let(:entity_hash) { entity.as_json }
|
|
|
|
|
|
|
|
it 'matches json schema' do
|
|
|
|
expect(entity.to_json).to match_schema('entities/member_user')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'correctly exposes `avatar_url`' do
|
|
|
|
avatar_url = 'https://www.gravatar.com/avatar/c4637cb869d5f94c3193bde4f23d4cdc?s=80&d=identicon'
|
|
|
|
allow(user).to receive(:avatar_url).and_return(avatar_url)
|
|
|
|
|
|
|
|
expect(entity_hash[:avatar_url]).to match(avatar_url)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'correctly exposes `blocked`' do
|
|
|
|
allow(user).to receive(:blocked?).and_return(true)
|
|
|
|
|
|
|
|
expect(entity_hash[:blocked]).to be(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'correctly exposes `two_factor_enabled`' do
|
|
|
|
allow(user).to receive(:two_factor_enabled?).and_return(true)
|
|
|
|
|
|
|
|
expect(entity_hash[:two_factor_enabled]).to be(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'correctly exposes `status.emoji`' do
|
|
|
|
expect(entity_hash[:status][:emoji]).to match(emoji)
|
|
|
|
end
|
2022-03-22 11:07:25 -04:00
|
|
|
|
|
|
|
it 'correctly exposes `created_at`' do
|
|
|
|
expect(entity_hash[:created_at]).to be(user.created_at)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'correctly exposes `last_activity_on`' do
|
|
|
|
expect(entity_hash[:last_activity_on]).to be(user.last_activity_on)
|
|
|
|
end
|
2021-01-14 13:10:59 -05:00
|
|
|
end
|