Read about our upcoming Code of Conduct on this issue

participants_service_spec.rb 1.12 KB
Newer Older
hogewest's avatar
hogewest committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
require 'spec_helper'

describe Projects::ParticipantsService, services: true do
  describe '#groups' do
    describe 'avatar_url' do
      let(:project) { create(:empty_project, :public) }
      let(:group) { create(:group, avatar: fixture_file_upload(Rails.root + 'spec/fixtures/dk.png')) }
      let(:user) { create(:user) }
      let!(:group_member) { create(:group_member, group: group, user: user) }

      it 'should return an url for the avatar' do
        participants = described_class.new(project, user)
        groups = participants.groups

        expect(groups.size).to eq 1
16
        expect(groups.first[:avatar_url]).to eq("/uploads/group/avatar/#{group.id}/dk.png")
hogewest's avatar
hogewest committed
17
18
19
20
21
22
23
24
25
26
      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))

        participants = described_class.new(project, user)
        groups = participants.groups

        expect(groups.size).to eq 1
27
        expect(groups.first[:avatar_url]).to eq("/gitlab/uploads/group/avatar/#{group.id}/dk.png")
hogewest's avatar
hogewest committed
28
29
30
31
      end
    end
  end
end