Commit df3a42cc authored by Manoj M J's avatar Manoj M J Committed by Fabio Pitino

Add custom avatars for Alert and Support Bot

This change adds custom avatars for
Alert and Support Bot.
parent 1f256b6c
......@@ -36,6 +36,12 @@ module Avatarable
end
end
class_methods do
def bot_avatar(image:)
Rails.root.join('app', 'assets', 'images', 'bot_avatars', image).open
end
end
def avatar_type
unless self.avatar.image?
errors.add :avatar, "file format is not supported. Please try one of the following supported formats: #{AvatarUploader::SAFE_IMAGE_EXT.join(', ')}"
......
......@@ -642,6 +642,7 @@ class User < ApplicationRecord
unique_internal(where(user_type: :alert_bot), 'alert-bot', email_pattern) do |u|
u.bio = 'The GitLab alert bot'
u.name = 'GitLab Alert Bot'
u.avatar = bot_avatar(image: 'alert-bot.png')
end
end
......@@ -661,6 +662,7 @@ class User < ApplicationRecord
unique_internal(where(user_type: :support_bot), 'support-bot', email_pattern) do |u|
u.bio = 'The GitLab support bot used for Service Desk'
u.name = 'GitLab Support Bot'
u.avatar = bot_avatar(image: 'support-bot.png')
end
end
......
---
title: Add custom avatars for Alert and Support Bot
merge_request: 36269
author:
type: added
......@@ -4781,9 +4781,21 @@ RSpec.describe User do
end
end
shared_examples 'bot user avatars' do |bot_type, avatar_filename|
it 'sets the custom avatar for the created bot' do
bot_user = described_class.public_send(bot_type)
expect(bot_user.avatar.url).to be_present
expect(bot_user.avatar.filename).to eq(avatar_filename)
end
end
it_behaves_like 'bot users', :alert_bot
it_behaves_like 'bot users', :support_bot
it_behaves_like 'bot users', :migration_bot
it_behaves_like 'bot users', :ghost
it_behaves_like 'bot user avatars', :alert_bot, 'alert-bot.png'
it_behaves_like 'bot user avatars', :support_bot, 'support-bot.png'
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment