1
0
зеркало из https://github.com/glebtv/telegram-bot.git synced 2026-09-03 17:55:52 +03:00

Fixed controller crashes on unsupported update types

Этот коммит содержится в:
Max Melentiev
2016-05-31 10:38:36 +03:00
родитель a52e7ff31b
Коммит 33a1220c5f
5 изменённых файлов: 45 добавлений и 18 удалений

Просмотреть файл

@@ -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} }