spec/acceptance/realtime/channel_history_spec.rb in ably-1.1.6 vs spec/acceptance/realtime/channel_history_spec.rb in ably-1.1.7

- old
+ new

@@ -181,9 +181,34 @@ end end end end + context 'when channel receives update event after an attachment' do + before do + channel.on(:attached) do + channel.publish(event, message_after_attach) do + subsequent_serial = channel.properties.attach_serial.dup.tap { |serial| serial[-1] = '1' } + attached_message = Ably::Models::ProtocolMessage.new(action: 11, channel: channel_name, flags: 0, channel_serial: subsequent_serial) + client.connection.__incoming_protocol_msgbus__.publish :protocol_message, attached_message + end + end + end + + it 'updates attach_serial' do + rest_channel.publish event, message_before_attach + + channel.on(:update) do + channel.history(until_attach: true) do |messages| + expect(messages.items.count).to eql(2) + stop_reactor + end + end + + channel.attach + end + end + context 'and two pages of messages' do it 'retrieves two pages of messages before channel was attached' do 10.times { rest_channel.publish event, message_before_attach } channel.attach do