diff --git a/.pubnub.yml b/.pubnub.yml index 177c2a659..4eb3d43e9 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,6 +1,11 @@ --- -version: "6.2.0" +version: "6.2.1" changelog: + - date: 2026-11-23 + version: v6.2.1 + changes: + - type: bug + text: "Preserve block callbacks in async history methods." - date: 2026-10-21 version: v6.2.0 changes: @@ -661,7 +666,7 @@ sdks: - x86-64 - distribution-type: package distribution-repository: RubyGems - package-name: pubnub-6.2.0.gem + package-name: pubnub-6.2.1.gem location: https://rubygems.org/gems/pubnub requires: - name: addressable @@ -766,8 +771,8 @@ sdks: - x86-64 - distribution-type: library distribution-repository: GitHub release - package-name: pubnub-6.2.0.gem - location: https://github.com/pubnub/ruby/releases/download/v6.2.0/pubnub-6.2.0.gem + package-name: pubnub-6.2.1.gem + location: https://github.com/pubnub/ruby/releases/download/v6.2.1/pubnub-6.2.1.gem requires: - name: addressable min-version: 2.0.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a3a2f408..83a6e39cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v6.2.1 +November 23 2026 + +#### Fixed +- Preserve block callbacks in async history methods. Fixed the following issues reported by [@pcbeingused333](https://github.com/pcbeingused333): [#182](https://github.com/pubnub/ruby/issues/182). + ## v6.2.0 October 21 2026 diff --git a/Gemfile.lock b/Gemfile.lock index 7436756db..a0f17b122 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - pubnub (6.2.0) + pubnub (6.2.1) addressable (>= 2.0.0) base64 concurrent-ruby (~> 1.3.4) diff --git a/VERSION b/VERSION index 6abaeb2f9..024b066c0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.2.0 +6.2.1 diff --git a/lib/pubnub/client/paged_history.rb b/lib/pubnub/client/paged_history.rb index 42515ab4a..9ee3ae2c5 100644 --- a/lib/pubnub/client/paged_history.rb +++ b/lib/pubnub/client/paged_history.rb @@ -25,7 +25,7 @@ def all_history_messages(options = {}, &block) if options[:http_sync] sync_all_history_messages(channel, include_token, page_size, reverse, maximum, callback, start: start_tt, end: end_tt) else - async_all_history_messages(options) + async_all_history_messages(options.merge(callback: callback)) end end @@ -42,7 +42,7 @@ def paged_history(options = {}, &block) if options[:http_sync] sync_paged_history(channel, page, limit, include_token, callback, start: start_tt, end: end_tt) else - async_paged_history(options) + async_paged_history(options.merge(callback: callback)) end end diff --git a/lib/pubnub/version.rb b/lib/pubnub/version.rb index 6a568a699..08fbf9e5d 100644 --- a/lib/pubnub/version.rb +++ b/lib/pubnub/version.rb @@ -1,4 +1,4 @@ # Toplevel Pubnub module. module Pubnub - VERSION = '6.2.0'.freeze + VERSION = '6.2.1'.freeze end diff --git a/spec/lib/paged_history_spec.rb b/spec/lib/paged_history_spec.rb new file mode 100644 index 000000000..a4d2de24a --- /dev/null +++ b/spec/lib/paged_history_spec.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +require 'concurrent' +require_relative '../../lib/pubnub/client/paged_history' + +RSpec.describe Pubnub::Client::PagedHistory do + let(:client) { Class.new { include Pubnub::Client::PagedHistory }.new } + let(:envelope) do + double(status: { category: :ack }, + result: { data: { messages: ['message'], start: '1', end: '2' } }) + end + + before do + allow(client).to receive(:history).and_return(envelope) + allow(client).to receive(:envelope_with_messages).and_return(envelope) + end + + [:paged_history, :all_history_messages].each do |method| + [true, false].each do |sync| + it "delivers #{method} results to a block with http_sync=#{sync}" do + received = [] + options = { channel: 'demo', http_sync: sync }.freeze + result = client.public_send(method, options) { |value| received << value } + result.value! if result.is_a?(Concurrent::Future) + + expect(received).to eq([envelope]) + end + end + + it "prefers the explicit #{method} callback over a block asynchronously" do + received = [] + callback = ->(value) { received << value } + result = client.public_send(method, channel: 'demo', callback: callback) do + raise 'The explicit callback should take precedence' + end + result.value! + + expect(received).to eq([envelope]) + end + + it "respects an explicit nil #{method} callback asynchronously" do + result = client.public_send(method, channel: 'demo', callback: nil) do + raise 'An explicit nil callback should suppress the block' + end + + expect { result.value! }.not_to raise_error + end + end +end