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 @@ -183,7 +183,7 @@ class BufferedConsumer
# the constructor, the *_endpoint constructor arguments are
# ignored.
def initialize(events_endpoint=nil, update_endpoint=nil, import_endpoint=nil, max_buffer_length=MAX_LENGTH, &block)
@max_length = [max_buffer_length, MAX_LENGTH].min
@max_length = [max_buffer_length, MAX_LENGTH].max
@buffers = {
:event => [],
:profile_update => [],
Expand Down
5 changes: 5 additions & 0 deletions spec/mixpanel-ruby/consumer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ def request(*args)
context 'Default BufferedConsumer' do
subject { Mixpanel::BufferedConsumer.new(nil, nil, nil, max_length) }

it 'should use the max for max_length' do
consumer = Mixpanel::BufferedConsumer.new(nil, nil, nil, 100)
expect(consumer.instance_variable_get(:@max_length)).to eq(100)
end

it 'should not send a request for a single message until flush is called' do
stub_request(:any, 'https://api.mixpanel.com/track').to_return({:body => '{"status": 1, "error": null}'})
subject.send!(:event, {'data' => 'TEST EVENT 1'}.to_json)
Expand Down