ably 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ably/rest/channel.rb +1 -1
- data/lib/ably/rest/presence.rb +1 -1
- data/lib/ably/version.rb +1 -1
- data/spec/acceptance/rest/channel_spec.rb +20 -1
- data/spec/acceptance/rest/presence_spec.rb +26 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c9fbb2d2e98f6d82d7034718820679ab772adc9
|
4
|
+
data.tar.gz: 33f0173c647e92e77724c48c761a5aefef608360
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efd51a591e92dc64137f257beaabb3c9b909166f19abeb7ee37a8895c5e6dec7069c7c02f7c326240b6fbd628831c5dd718f87f0fd4174a4bb8a2d8116926622
|
7
|
+
data.tar.gz: 1e0ef0ba81c9dcbc7ba86c44187c6afb2ff16f6841c96b430a461c1b121c63e5b76ab87c1d696428769f8948aee0774a061e183131e3b543d46e414919ccfe1c
|
data/lib/ably/rest/channel.rb
CHANGED
data/lib/ably/rest/presence.rb
CHANGED
data/lib/ably/version.rb
CHANGED
@@ -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/#{
|
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/#{
|
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/#{
|
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/#{
|
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/#{
|
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/#{
|
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/#{
|
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/#{
|
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 }
|