blob: dcd4ef6acfbc7f62173e51a12842e9022f386572 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe MergeRequestUserEntity do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:request) { EntityRequest.new(project: project, current_user: user) }
let(:entity) do
described_class.new(user, request: request)
end
context 'as json' do
subject { entity.as_json }
it 'exposes needed attributes' do
expect(subject).to include(:id, :name, :username, :state, :avatar_url, :web_url, :can_merge)
end
context 'when `status` is not preloaded' do
it 'does not expose the availability attribute' do
expect(subject).not_to include(:availability)
end
end
context 'when `status` is preloaded' do
before do
user.create_status!(availability: :busy)
user.status # make sure `status` is loaded
end
it 'exposes the availibility attribute' do
expect(subject[:availability]).to eq('busy')
end
end
end
end
|