blob: 4b6d0c5136305b87c9d50a1f1972bb4944c7b187 (
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
require 'spec_helper'
describe Projects::ParticipantsService do
describe '#groups' do
set(:user) { create(:user) }
set(:project) { create(:project, :public) }
let(:service) { described_class.new(project, user) }
it 'avoids N+1 queries' do
group_1 = create(:group)
group_1.add_owner(user)
service.groups # Run general application warmup queries
control_count = ActiveRecord::QueryRecorder.new { service.groups }.count
group_2 = create(:group)
group_2.add_owner(user)
expect { service.groups }.not_to exceed_query_limit(control_count)
end
it 'returns correct user counts for groups' do
group_1 = create(:group)
group_1.add_owner(user)
group_1.add_owner(create(:user))
group_2 = create(:group)
group_2.add_owner(user)
create(:group_member, :access_request, group: group_2, user: create(:user))
expect(service.groups).to contain_exactly(
a_hash_including(name: group_1.full_name, count: 2),
a_hash_including(name: group_2.full_name, count: 1)
)
end
describe 'avatar_url' do
let(:group) { create(:group, avatar: fixture_file_upload('spec/fixtures/dk.png')) }
before do
group.add_owner(user)
end
it 'should return an url for the avatar' do
expect(service.groups.size).to eq 1
expect(service.groups.first[:avatar_url]).to eq("/uploads/-/system/group/avatar/#{group.id}/dk.png")
end
it 'should return an url for the avatar with relative url' do
stub_config_setting(relative_url_root: '/gitlab')
stub_config_setting(url: Settings.send(:build_gitlab_url))
expect(service.groups.size).to eq 1
expect(service.groups.first[:avatar_url]).to eq("/gitlab/uploads/-/system/group/avatar/#{group.id}/dk.png")
end
end
end
end
|