debian-mirror-gitlab/spec/lib/microsoft_teams/notifier_spec.rb

58 lines
1.9 KiB
Ruby
Raw Normal View History

2019-12-04 20:38:33 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
describe MicrosoftTeams::Notifier do
subject { described_class.new(webhook_url) }
let(:webhook_url) { 'https://example.gitlab.com/'}
let(:header) { { 'Content-Type' => 'application/json' } }
let(:options) do
{
title: 'JohnDoe4/project2',
2018-11-08 19:23:39 +05:30
summary: '[[JohnDoe4/project2](http://localhost/namespace2/gitlabhq)] Issue [#1 Awesome issue](http://localhost/namespace2/gitlabhq/issues/1) opened by user6',
2017-08-17 22:00:37 +05:30
activity: {
title: 'Issue opened by user6',
subtitle: 'in [JohnDoe4/project2](http://localhost/namespace2/gitlabhq)',
text: '[#1 Awesome issue](http://localhost/namespace2/gitlabhq/issues/1)',
image: 'http://someimage.com'
},
attachments: 'please fix'
}
end
let(:body) do
{
'sections' => [
{
'activityTitle' => 'Issue opened by user6',
'activitySubtitle' => 'in [JohnDoe4/project2](http://localhost/namespace2/gitlabhq)',
'activityText' => '[#1 Awesome issue](http://localhost/namespace2/gitlabhq/issues/1)',
'activityImage' => 'http://someimage.com'
},
{
'title' => 'Details',
'facts' => [
{
'name' => 'Attachments',
'value' => 'please fix'
}
]
}
],
'title' => 'JohnDoe4/project2',
'summary' => '[[JohnDoe4/project2](http://localhost/namespace2/gitlabhq)] Issue [#1 Awesome issue](http://localhost/namespace2/gitlabhq/issues/1) opened by user6'
}
end
describe '#ping' do
before do
stub_request(:post, webhook_url).with(body: JSON(body), headers: { 'Content-Type' => 'application/json' }).to_return(status: 200, body: "", headers: {})
end
2018-12-13 13:39:08 +05:30
it 'expects to receive successful answer' do
2017-08-17 22:00:37 +05:30
expect(subject.ping(options)).to be true
end
end
end