Commit 2129455f authored by Luke Duncalfe's avatar Luke Duncalfe

Merge branch 'update-discord-embed' into 'master'

Update the Discord integration embed

See merge request gitlab-org/gitlab!65893
parents 0efdbdd0 e4f38f3f
......@@ -54,6 +54,8 @@ module Integrations
builder.add_embed do |embed|
embed.author = Discordrb::Webhooks::EmbedAuthor.new(name: message.user_name, icon_url: message.user_avatar)
embed.description = (message.pretext + "\n" + Array.wrap(message.attachments).join("\n")).gsub(ATTACHMENT_REGEX, " \\k<entry> - \\k<name>\n")
embed.colour = 16543014 # The hex "fc6d26" as an Integer
embed.timestamp = Time.now.utc
end
end
rescue RestClient::Exception => error
......
......@@ -11,7 +11,9 @@ RSpec.describe Integrations::Discord do
embeds: [
include(
author: include(name: be_present),
description: be_present
description: be_present,
color: be_present,
timestamp: be_present
)
]
}
......@@ -47,6 +49,7 @@ RSpec.describe Integrations::Discord do
allow(client).to receive(:execute).and_yield(builder)
end
freeze_time do
subject.execute(sample_data)
expect(builder.to_json_hash[:embeds].first).to include(
......@@ -54,8 +57,11 @@ RSpec.describe Integrations::Discord do
author: hash_including(
icon_url: start_with('https://www.gravatar.com/avatar/'),
name: user.name
),
color: 16543014,
timestamp: Time.now.utc.iso8601
)
)
end
end
context 'DNS rebind to local address' do
......
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