Skip to content

Commit 4c2f627

Browse files
committed
fix(http-stream): Add HTTPS support
1 parent 2a1551b commit 4c2f627

File tree

6 files changed

+31
-6
lines changed

6 files changed

+31
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
- Documentation for error handlers
1919
- Tests for error handlers
2020
- New method to build Message from json
21+
22+
## [0.1.2] - 2019-05-02
23+
### Added
24+
- HTTPS targets support

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
active_record_streams (0.1.1)
4+
active_record_streams (0.1.2)
55
activerecord (~> 4.2.10)
66
aws-sdk (~> 2.11.9)
77

@@ -93,4 +93,4 @@ DEPENDENCIES
9393
rubocop-performance (~> 1.1.0)
9494

9595
BUNDLED WITH
96-
1.17.1
96+
1.17.3

lib/active_record_streams/publishers/http_stream.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,15 @@ def request
5858
end
5959

6060
def http
61-
@http ||= Net::HTTP.new(uri.host, uri.port)
61+
@http ||= begin
62+
http_client = Net::HTTP.new(uri.host, uri.port)
63+
http_client.use_ssl = true if https?
64+
http_client
65+
end
66+
end
67+
68+
def https?
69+
uri.scheme == 'https'
6270
end
6371

6472
def uri

lib/active_record_streams/publishers/http_stream_spec.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
let(:request) { double('body=': nil) }
1414
let(:response) { double(code: 200) }
15-
let(:http_client) { double('body=': nil, request: response) }
15+
let(:http_client) { double('body=': nil, 'use_ssl=': nil, request: response) }
1616
let(:message) { double(json: '{}') }
1717

1818
subject do
@@ -88,5 +88,18 @@
8888
subject.publish(actual_table_name, message)
8989
end
9090
end
91+
92+
context 'https target' do
93+
let(:url) { 'https://hello.world' }
94+
95+
it 'sends event to an https target' do
96+
expect(http_client).to receive(:use_ssl=).with(true)
97+
98+
subject.publish(actual_table_name, message)
99+
100+
expect(request).to have_received(:body=).with(message.json)
101+
expect(http_client).to have_received(:request).with(request)
102+
end
103+
end
91104
end
92105
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module ActiveRecordStreams
4-
VERSION = '0.1.1'
4+
VERSION = '0.1.2'
55
end

lib/active_record_streams/version_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
RSpec.describe ActiveRecordStreams::VERSION do
66
it 'has a version number' do
7-
expect(subject).to eq('0.1.1')
7+
expect(subject).to eq('0.1.2')
88
end
99
end

0 commit comments

Comments
 (0)