diff options
-rw-r--r-- | app/services/projects/participants_service.rb | 2 | ||||
-rw-r--r-- | changelogs/unreleased/fix-broken-url-on-group-avatar.yml | 4 | ||||
-rw-r--r-- | spec/services/projects/participants_service_spec.rb | 32 |
3 files changed, 37 insertions, 1 deletions
diff --git a/app/services/projects/participants_service.rb b/app/services/projects/participants_service.rb index 6040391fd94..96c363c8d1a 100644 --- a/app/services/projects/participants_service.rb +++ b/app/services/projects/participants_service.rb @@ -36,7 +36,7 @@ module Projects def groups current_user.authorized_groups.sort_by(&:path).map do |group| count = group.users.count - { username: group.path, name: group.name, count: count, avatar_url: group.avatar.url } + { username: group.path, name: group.name, count: count, avatar_url: group.avatar_url } end end diff --git a/changelogs/unreleased/fix-broken-url-on-group-avatar.yml b/changelogs/unreleased/fix-broken-url-on-group-avatar.yml new file mode 100644 index 00000000000..7ce22b4826e --- /dev/null +++ b/changelogs/unreleased/fix-broken-url-on-group-avatar.yml @@ -0,0 +1,4 @@ +--- +title: Fix broken url on group avatar +merge_request: 8464 +author: hogewest diff --git a/spec/services/projects/participants_service_spec.rb b/spec/services/projects/participants_service_spec.rb new file mode 100644 index 00000000000..063b3bd76eb --- /dev/null +++ b/spec/services/projects/participants_service_spec.rb @@ -0,0 +1,32 @@ +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(:base_url) { Settings.send(:build_base_gitlab_url) } + 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 + expect(groups.first[:avatar_url]).to eq "#{base_url}/uploads/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)) + + participants = described_class.new(project, user) + groups = participants.groups + + expect(groups.size).to eq 1 + expect(groups.first[:avatar_url]).to eq "#{base_url}/gitlab/uploads/group/avatar/#{group.id}/dk.png" + end + end + end +end |