diff options
author | Stan Hu <stanhu@gmail.com> | 2017-07-14 07:38:26 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-07-14 07:38:26 +0300 |
commit | 0e23d1a74ff6283076e9a1d74eccfc5ba6419fd8 (patch) | |
tree | acbd4550fd800053fac5ee70acac972bd3c4ffe9 /spec/requests/api/internal_spec.rb | |
parent | dbcc0e03ac82d6b90fc93b1fefac8ce80c741178 (diff) |
Handle case when BroadcastMessage.current is nil
Somehow Rails.cache.fetch occasionally returns `nil` values, which causes
this endpoint to crash.
Closes #35094
Diffstat (limited to 'spec/requests/api/internal_spec.rb')
-rw-r--r-- | spec/requests/api/internal_spec.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/requests/api/internal_spec.rb b/spec/requests/api/internal_spec.rb index 453eb4683a0..beaaf346283 100644 --- a/spec/requests/api/internal_spec.rb +++ b/spec/requests/api/internal_spec.rb @@ -35,6 +35,17 @@ describe API::Internal do expect(json_response).to be_empty end end + + context 'nil broadcast message' do + it 'returns nothing' do + allow(BroadcastMessage).to receive(:current).and_return(nil) + + get api('/internal/broadcast_message'), secret_token: secret_token + + expect(response).to have_http_status(200) + expect(json_response).to be_empty + end + end end describe 'GET /internal/broadcast_messages' do |