ably 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec00d1068f71b56bbd617d688762b9736c3dc905
4
- data.tar.gz: 43c524b37e87cd8d5b028b3e21211a8d175096d5
3
+ metadata.gz: 3c9fbb2d2e98f6d82d7034718820679ab772adc9
4
+ data.tar.gz: 33f0173c647e92e77724c48c761a5aefef608360
5
5
  SHA512:
6
- metadata.gz: 54e6043bc398bf76397bab60b9c9922824c79c96223421cfb0496ce70ef83339300a799d3fe4cf2b440c1834ca5ecda634c060f63a769f237674051bc7e4120e
7
- data.tar.gz: 1377c7533da5ccc4996237c9b345ede359548e5ae1845f50f1c590e2d4b6759bd7f3fa194911404158b8935c5fa76b36757e5d6b57007b8d2bea9b858c3c5c0c
6
+ metadata.gz: efd51a591e92dc64137f257beaabb3c9b909166f19abeb7ee37a8895c5e6dec7069c7c02f7c326240b6fbd628831c5dd718f87f0fd4174a4bb8a2d8116926622
7
+ data.tar.gz: 1e0ef0ba81c9dcbc7ba86c44187c6afb2ff16f6841c96b430a461c1b121c63e5b76ab87c1d696428769f8948aee0774a061e183131e3b543d46e414919ccfe1c
@@ -130,7 +130,7 @@ module Ably
130
130
 
131
131
  private
132
132
  def base_path
133
- "/channels/#{Addressable::URI.encode(name)}"
133
+ "/channels/#{URI.encode_www_form_component(name)}"
134
134
  end
135
135
 
136
136
  def decode_message(message)
@@ -84,7 +84,7 @@ module Ably
84
84
 
85
85
  private
86
86
  def base_path
87
- "/channels/#{Addressable::URI.encode(channel.name)}/presence"
87
+ "/channels/#{URI.encode_www_form_component(channel.name)}/presence"
88
88
  end
89
89
 
90
90
  def decode_message(presence_message)
@@ -1,5 +1,5 @@
1
1
  module Ably
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  PROTOCOL_VERSION = '1.0'
4
4
 
5
5
  # Allow a variant to be configured for all instances of this client library
@@ -256,6 +256,25 @@ describe Ably::Rest::Channel do
256
256
  end
257
257
  end
258
258
  end
259
+
260
+ context 'with a non ASCII channel name' do
261
+ let(:channel_name) { 'foo:¡€≤`☃' }
262
+ let(:channel_name_encoded) { 'foo%3A%C2%A1%E2%82%AC%E2%89%A4%60%E2%98%83' }
263
+ let(:endpoint) { client.endpoint }
264
+ let(:channel) { client.channels.get(channel_name) }
265
+
266
+ context 'stubbed', :webmock do
267
+ let!(:get_stub) {
268
+ stub_request(:post, "#{endpoint}/channels/#{channel_name_encoded}/publish").
269
+ to_return(:body => '{}', :headers => { 'Content-Type' => 'application/json' })
270
+ }
271
+
272
+ it 'correctly encodes the channel name' do
273
+ channel.publish('foo')
274
+ expect(get_stub).to have_been_requested
275
+ end
276
+ end
277
+ end
259
278
  end
260
279
 
261
280
  describe '#history' do
@@ -374,7 +393,7 @@ describe Ably::Rest::Channel do
374
393
  let!(:history_stub) {
375
394
  query_params = default_history_options
376
395
  .merge(option => milliseconds).map { |k, v| "#{k}=#{v}" }.join('&')
377
- stub_request(:get, "#{endpoint}/channels/#{Addressable::URI.encode(channel_name)}/messages?#{query_params}").
396
+ stub_request(:get, "#{endpoint}/channels/#{URI.encode_www_form_component(channel_name)}/messages?#{query_params}").
378
397
  to_return(:body => '{}', :headers => { 'Content-Type' => 'application/json' })
379
398
  }
380
399
 
@@ -73,7 +73,7 @@ describe Ably::Rest::Presence do
73
73
  end
74
74
  let!(:get_stub) {
75
75
  query_params = query_options.map { |k, v| "#{k}=#{v}" }.join('&')
76
- stub_request(:get, "#{endpoint}/channels/#{Addressable::URI.encode(channel_name)}/presence?#{query_params}").
76
+ stub_request(:get, "#{endpoint}/channels/#{URI.encode_www_form_component(channel_name)}/presence?#{query_params}").
77
77
  to_return(:body => '{}', :headers => { 'Content-Type' => 'application/json' })
78
78
  }
79
79
  let(:channel_name) { random_str }
@@ -111,6 +111,25 @@ describe Ably::Rest::Presence do
111
111
  expect(fixtures_channel.presence.get(connection_id: 'does.not.exist').items).to be_empty
112
112
  end
113
113
  end
114
+
115
+ context 'with a non ASCII channel name' do
116
+ let(:channel_name) { 'foo:¡€≤`☃' }
117
+ let(:channel_name_encoded) { 'foo%3A%C2%A1%E2%82%AC%E2%89%A4%60%E2%98%83' }
118
+ let(:endpoint) { client.endpoint }
119
+ let(:channel) { client.channels.get(channel_name) }
120
+
121
+ context 'stubbed', :webmock do
122
+ let!(:get_stub) {
123
+ stub_request(:get, "#{endpoint}/channels/#{channel_name_encoded}/presence?limit=100").
124
+ to_return(:body => '{}', :headers => { 'Content-Type' => 'application/json' })
125
+ }
126
+
127
+ it 'correctly encodes the channel name' do
128
+ channel.presence.get
129
+ expect(get_stub).to have_been_requested
130
+ end
131
+ end
132
+ end
114
133
  end
115
134
 
116
135
  describe '#history' do
@@ -194,7 +213,7 @@ describe Ably::Rest::Presence do
194
213
  context 'limit options', :webmock do
195
214
  let!(:history_stub) {
196
215
  query_params = history_options.map { |k, v| "#{k}=#{v}" }.join('&')
197
- stub_request(:get, "#{endpoint}/channels/#{Addressable::URI.encode(channel_name)}/presence/history?#{query_params}").
216
+ stub_request(:get, "#{endpoint}/channels/#{URI.encode_www_form_component(channel_name)}/presence/history?#{query_params}").
198
217
  to_return(:body => '{}', :headers => { 'Content-Type' => 'application/json' })
199
218
  }
200
219
 
@@ -234,7 +253,7 @@ describe Ably::Rest::Presence do
234
253
  }
235
254
  let!(:history_stub) {
236
255
  query_params = history_options.map { |k, v| "#{k}=#{v}" }.join('&')
237
- stub_request(:get, "#{endpoint}/channels/#{Addressable::URI.encode(channel_name)}/presence/history?#{query_params}").
256
+ stub_request(:get, "#{endpoint}/channels/#{URI.encode_www_form_component(channel_name)}/presence/history?#{query_params}").
238
257
  to_return(:body => '{}', :headers => { 'Content-Type' => 'application/json' })
239
258
  }
240
259
 
@@ -338,7 +357,7 @@ describe Ably::Rest::Presence do
338
357
 
339
358
  context '#get' do
340
359
  let!(:get_stub) {
341
- stub_request(:get, "#{endpoint}/channels/#{Addressable::URI.encode(channel_name)}/presence?limit=100").
360
+ stub_request(:get, "#{endpoint}/channels/#{URI.encode_www_form_component(channel_name)}/presence?limit=100").
342
361
  to_return(:body => serialized_encoded_message, :headers => { 'Content-Type' => content_type })
343
362
  }
344
363
 
@@ -355,7 +374,7 @@ describe Ably::Rest::Presence do
355
374
 
356
375
  context '#history' do
357
376
  let!(:history_stub) {
358
- stub_request(:get, "#{endpoint}/channels/#{Addressable::URI.encode(channel_name)}/presence/history?direction=backwards&limit=100").
377
+ stub_request(:get, "#{endpoint}/channels/#{URI.encode_www_form_component(channel_name)}/presence/history?direction=backwards&limit=100").
359
378
  to_return(:body => serialized_encoded_message, :headers => { 'Content-Type' => content_type })
360
379
  }
361
380
 
@@ -385,7 +404,7 @@ describe Ably::Rest::Presence do
385
404
  context '#get' do
386
405
  let(:client_options) { default_options.merge(log_level: :fatal) }
387
406
  let!(:get_stub) {
388
- stub_request(:get, "#{endpoint}/channels/#{Addressable::URI.encode(channel_name)}/presence?limit=100").
407
+ stub_request(:get, "#{endpoint}/channels/#{URI.encode_www_form_component(channel_name)}/presence?limit=100").
389
408
  to_return(:body => serialized_encoded_message_with_invalid_encoding, :headers => { 'Content-Type' => content_type })
390
409
  }
391
410
  let(:presence_message) { presence.get.items.first }
@@ -409,7 +428,7 @@ describe Ably::Rest::Presence do
409
428
  context '#history' do
410
429
  let(:client_options) { default_options.merge(log_level: :fatal) }
411
430
  let!(:history_stub) {
412
- stub_request(:get, "#{endpoint}/channels/#{Addressable::URI.encode(channel_name)}/presence/history?direction=backwards&limit=100").
431
+ stub_request(:get, "#{endpoint}/channels/#{URI.encode_www_form_component(channel_name)}/presence/history?direction=backwards&limit=100").
413
432
  to_return(:body => serialized_encoded_message_with_invalid_encoding, :headers => { 'Content-Type' => content_type })
414
433
  }
415
434
  let(:presence_message) { presence.history.items.first }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ably
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lewis Marshall