Commit e80cdca6 authored by Stan Hu's avatar Stan Hu

Merge branch 'fix_microsoft_teams_kwags_warnings' into 'master'

Fix kwargs warning in microsoft_teams notifier

See merge request gitlab-org/gitlab!47833
parents 8eb82362 aab584e1
...@@ -14,7 +14,7 @@ module MicrosoftTeams ...@@ -14,7 +14,7 @@ module MicrosoftTeams
response = Gitlab::HTTP.post( response = Gitlab::HTTP.post(
@webhook.to_str, @webhook.to_str,
headers: @header, headers: @header,
body: body(options) body: body(**options)
) )
result = true if response result = true if response
...@@ -27,14 +27,13 @@ module MicrosoftTeams ...@@ -27,14 +27,13 @@ module MicrosoftTeams
private private
def body(options = {}) def body(title: nil, summary: nil, attachments: nil, activity:)
result = { 'sections' => [] } result = { 'sections' => [] }
result['title'] = options[:title] result['title'] = title
result['summary'] = options[:summary] result['summary'] = summary
result['sections'] << MicrosoftTeams::Activity.new(options[:activity]).prepare result['sections'] << MicrosoftTeams::Activity.new(**activity).prepare
attachments = options[:attachments]
unless attachments.blank? unless attachments.blank?
result['sections'] << { text: attachments } result['sections'] << { text: attachments }
end end
......
...@@ -51,11 +51,11 @@ RSpec.describe MicrosoftTeams::Notifier do ...@@ -51,11 +51,11 @@ RSpec.describe MicrosoftTeams::Notifier do
describe '#body' do describe '#body' do
it 'returns Markdown-based body when HTML was passed' do it 'returns Markdown-based body when HTML was passed' do
expect(subject.send(:body, options)).to eq(body.to_json) expect(subject.send(:body, **options)).to eq(body.to_json)
end end
it 'fails when empty Hash was passed' do it 'fails when empty Hash was passed' do
expect { subject.send(:body, {}) }.to raise_error(ArgumentError) expect { subject.send(:body, **{}) }.to raise_error(ArgumentError)
end end
end end
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