Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/mixpanel-ruby/consumer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def request(endpoint, form_data)
request.set_form_data(form_data)

client = Net::HTTP.new(uri.host, uri.port)
client.use_ssl = true
client.use_ssl = (uri.scheme == 'https')
client.open_timeout = 10
client.continue_timeout = 10
client.read_timeout = 10
Expand Down
12 changes: 12 additions & 0 deletions spec/mixpanel-ruby/consumer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'webmock'

require 'mixpanel-ruby/consumer'
require 'mixpanel-ruby/error'

describe Mixpanel::Consumer do
before { WebMock.reset! }
Expand Down Expand Up @@ -88,6 +89,17 @@ def request(*args)
it_behaves_like 'consumer'
end

context 'custom http endpoints' do
let(:endpoints) { ["http://example.com/track", nil, nil] }
subject { Mixpanel::Consumer.new(*endpoints) }

it 'should not use ssl' do
stub_request(:any, endpoints.first).to_return({:body => '{"status": 1, "error": null}'})
expect { subject.send!(:event, {'data' => 'TEST EVENT MESSAGE'}.to_json) }.not_to raise_error # WebMock::NetConnectNotAllowedError
expect(WebMock).to have_requested(:post, endpoints.first)
end
end

end

describe Mixpanel::BufferedConsumer do
Expand Down