Skip to content

Commit

Permalink
Support options on bulk subscription start
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-viney committed Aug 4, 2016
1 parent ddd410a commit 71d3040
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### 0.10 — Unreleased

-
- Added ability to pass shared subscription start options to `Lightstreamer::Session#bulk_subscription_start`

### 0.9 — August 4, 2016

Expand Down
6 changes: 4 additions & 2 deletions lib/lightstreamer/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,13 @@ def remove_subscription(subscription)
# if no error occurred.
#
# @param [Array<Subscription>] subscriptions The subscriptions to start.
# @param [Hash] options The options to start all subscriptions with. See {Subscription#start} for details on the
# supported options.
#
# @return [Array<LightstreamerError, nil>]
def bulk_subscription_start(*subscriptions)
def bulk_subscription_start(subscriptions, options = {})
request_bodies = subscriptions.map do |subscription|
args = subscription.start_control_request_args
args = subscription.start_control_request_args options
PostRequest.request_body({ LS_session: session_id, LS_op: args.first }.merge(args[1]))
end

Expand Down
6 changes: 3 additions & 3 deletions spec/lightstreamer/session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,19 @@
expect(Lightstreamer::PostRequest).to receive(:request_body)
.with(LS_session: 'session', LS_op: :add, LS_table: subscription.id, LS_mode: 'MERGE', LS_id: %w(item),
LS_schema: %w(field), LS_selector: 'selector', LS_data_adapter: nil, LS_requested_max_frequency: 0.0,
LS_snapshot: false)
LS_snapshot: true)
.and_return('body1')

expect(Lightstreamer::PostRequest).to receive(:request_body)
.with(LS_session: 'session', LS_op: :add, LS_table: second_subscription.id, LS_mode: 'MERGE', LS_schema: [],
LS_id: [], LS_selector: nil, LS_data_adapter: nil, LS_requested_max_frequency: 0.0, LS_snapshot: false)
LS_id: [], LS_selector: nil, LS_data_adapter: nil, LS_requested_max_frequency: 0.0, LS_snapshot: true)
.and_return('body2')

expect(Lightstreamer::PostRequest).to receive(:bulk_execute)
.with('http://a.com/lightstreamer/control.txt', %w(body1 body2))
.and_return([nil, Lightstreamer::Errors::InvalidDataAdapterError.new])

errors = session.bulk_subscription_start subscription, second_subscription
errors = session.bulk_subscription_start [subscription, second_subscription], snapshot: true

expect(errors.size).to eq(2)
expect(errors[0]).to be nil
Expand Down

0 comments on commit 71d3040

Please sign in to comment.