зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-03 17:55:52 +03:00
Fixed controller crashes on unsupported update types
Этот коммит содержится в:
@@ -26,6 +26,12 @@ RSpec.describe Telegram::Bot::UpdatesController::Session do
|
||||
def read
|
||||
session[:text]
|
||||
end
|
||||
|
||||
def action_missing(*)
|
||||
[:action_missing, session[:text]].tap do
|
||||
session[:text] = 'test'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,5 +45,13 @@ RSpec.describe Telegram::Bot::UpdatesController::Session do
|
||||
expect(subject.call(bot, build_message('/read', id: 2))).to eq nil
|
||||
expect(subject.call(other_bot, build_message('/read', id: 1))).to eq nil
|
||||
end
|
||||
|
||||
context 'payload is not supported' do
|
||||
let(:payload_type) { '_unsupported_' }
|
||||
it 'provides empty session' do
|
||||
2.times { expect(subject.call(bot)).to eq [:action_missing, nil] }
|
||||
expect(subject.call(other_bot)).to eq [:action_missing, nil]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -102,6 +102,11 @@ RSpec.describe Telegram::Bot::UpdatesController do
|
||||
it { should eq [false, payload_type, payload.values_at(:data)] }
|
||||
end
|
||||
|
||||
context 'when payload is not supported' do
|
||||
let(:payload_type) { '_unsupported_' }
|
||||
it { should eq [false, :unsupported_payload_type, []] }
|
||||
end
|
||||
|
||||
context 'when payload is message' do
|
||||
let(:payload_type) { 'message' }
|
||||
let(:payload) { {'text' => text} }
|
||||
|
||||
Ссылка в новой задаче
Block a user