diff options
author | Hordur Freyr Yngvason <hfyngvason@gitlab.com> | 2019-09-27 14:35:37 +0300 |
---|---|---|
committer | Hordur Freyr Yngvason <hfyngvason@gitlab.com> | 2019-11-21 18:09:57 +0300 |
commit | 729040717e887d33f776497eaefb8b8530dbe130 (patch) | |
tree | 5408aea2e573a7cd12b615031bb5b241952580ab /spec/initializers/hangouts_chat_http_override_spec.rb | |
parent | b5ad06174bb1de39438c90847abb86ac6988e944 (diff) |
Use Gitlab::HTTP for all chat notifications
Diffstat (limited to 'spec/initializers/hangouts_chat_http_override_spec.rb')
-rw-r--r-- | spec/initializers/hangouts_chat_http_override_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/initializers/hangouts_chat_http_override_spec.rb b/spec/initializers/hangouts_chat_http_override_spec.rb new file mode 100644 index 00000000000..0eee891799f --- /dev/null +++ b/spec/initializers/hangouts_chat_http_override_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'HangoutsChat::Sender Gitlab::HTTP override' do + describe 'HangoutsChat::Sender::HTTP#post' do + it 'calls Gitlab::HTTP.post with default protection settings' do + webhook_url = 'https://example.gitlab.com' + payload = { key: 'value' } + http = HangoutsChat::Sender::HTTP.new(webhook_url) + mock_response = double(response: 'the response') + + expect(Gitlab::HTTP).to receive(:post) + .with( + URI.parse(webhook_url), + body: payload.to_json, + headers: { 'Content-Type' => 'application/json' }, + parse: nil + ) + .and_return(mock_response) + + expect(http.post(payload)).to eq(mock_response.response) + end + + it_behaves_like 'a request using Gitlab::UrlBlocker' do + let(:http_method) { :post } + let(:url_blocked_error_class) { Gitlab::HTTP::BlockedUrlError } + + def make_request(uri) + HangoutsChat::Sender::HTTP.new(uri).post({}) + end + end + end +end |