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
response = Gitlab::HTTP.post(
@webhook.to_str,
headers: @header,
body: body(options)
body: body(**options)
)
result = true if response
......@@ -27,14 +27,13 @@ module MicrosoftTeams
private
def body(options = {})
def body(title: nil, summary: nil, attachments: nil, activity:)
result = { 'sections' => [] }
result['title'] = options[:title]
result['summary'] = options[:summary]
result['sections'] << MicrosoftTeams::Activity.new(options[:activity]).prepare
result['title'] = title
result['summary'] = summary
result['sections'] << MicrosoftTeams::Activity.new(**activity).prepare
attachments = options[:attachments]
unless attachments.blank?
result['sections'] << { text: attachments }
end
......
......@@ -51,11 +51,11 @@ RSpec.describe MicrosoftTeams::Notifier do
describe '#body' 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
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
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