|
262 | 262 | :occupied => false, |
263 | 263 | }) |
264 | 264 | end |
| 265 | + |
| 266 | + it "should not reset the http client connection after a 400 error" do |
| 267 | + api_path = %r{/apps/20/channels/mychannel} |
| 268 | + stub_request(:get, api_path).to_return({ :status => 400, :body => "Bad request" }) |
| 269 | + |
| 270 | + http_client = @client.sync_http_client |
| 271 | + expect(http_client).not_to receive(:reset_all) |
| 272 | + |
| 273 | + expect { @client.channel_info('mychannel') }.to raise_error(Pusher::Error) |
| 274 | + end |
| 275 | + |
| 276 | + it "should reset the http client connection after an unknown error status" do |
| 277 | + api_path = %r{/apps/20/channels/mychannel} |
| 278 | + stub_request(:get, api_path).to_return({ :status => 500, :body => "Server error" }) |
| 279 | + |
| 280 | + http_client = @client.sync_http_client |
| 281 | + expect(http_client).to receive(:reset_all).once |
| 282 | + |
| 283 | + expect { @client.channel_info('mychannel') }.to raise_error(Pusher::Error) |
| 284 | + end |
| 285 | + |
| 286 | + it "should succeed on a subsequent request after an unknown error status" do |
| 287 | + api_path = %r{/apps/20/channels/mychannel} |
| 288 | + stub_request(:get, api_path) |
| 289 | + .to_return({ :status => 500, :body => "Server error" }) |
| 290 | + .then |
| 291 | + .to_return({ :status => 200, :body => MultiJson.encode({ 'occupied' => false }) }) |
| 292 | + |
| 293 | + expect { @client.channel_info('mychannel') }.to raise_error(Pusher::Error) |
| 294 | + expect(@client.channel_info('mychannel')).to eq({ :occupied => false }) |
| 295 | + end |
| 296 | + |
| 297 | + it "should not reset the http client connection after a successful request" do |
| 298 | + api_path = %r{/apps/20/channels/mychannel} |
| 299 | + stub_request(:get, api_path).to_return({ |
| 300 | + :status => 200, |
| 301 | + :body => MultiJson.encode({ 'occupied' => false }) |
| 302 | + }) |
| 303 | + |
| 304 | + http_client = @client.sync_http_client |
| 305 | + expect(http_client).not_to receive(:reset_all) |
| 306 | + |
| 307 | + @client.channel_info('mychannel') |
| 308 | + end |
265 | 309 | end |
266 | 310 |
|
267 | 311 | describe '#channel_users' do |
|
0 commit comments