зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-03 17:55:52 +03:00
Add UpdatesController#webhook_request
Этот коммит содержится в:
@@ -10,4 +10,13 @@ RSpec.describe DefaultBotController, telegram_bot: :rails do
|
||||
subject { -> { dispatch_command :load_session } }
|
||||
it { should_not raise_error }
|
||||
end
|
||||
|
||||
describe '#dispatch' do
|
||||
it 'provides webhook_request' do
|
||||
expect(described_class).to receive(:dispatch).
|
||||
with(bot, hash_including('message'), instance_of(ActionDispatch::Request)).
|
||||
and_call_original
|
||||
dispatch_message :test
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,7 +24,8 @@ RSpec.describe Telegram::Bot::Middleware do
|
||||
end
|
||||
|
||||
it 'calls dispatch on controller' do
|
||||
expect(controller).to receive(:dispatch).with(bot, update)
|
||||
expect(controller).to receive(:dispatch).
|
||||
with(bot, update, instance_of(ActionDispatch::Request))
|
||||
subject
|
||||
end
|
||||
|
||||
|
||||
@@ -2,4 +2,13 @@ require 'telegram/bot/rspec/integration/poller'
|
||||
|
||||
RSpec.describe 'Poller integration spec', telegram_bot: :poller do
|
||||
include_examples 'shared integration examples'
|
||||
|
||||
describe '#dispatch' do
|
||||
it 'doesn`t provide webhook_request' do
|
||||
expect(controller_class).to receive(:dispatch).
|
||||
with(bot, hash_including('message')).
|
||||
and_call_original
|
||||
dispatch_message :test
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,4 +17,13 @@ RSpec.describe 'Rack integration spec', telegram_bot: :rack do
|
||||
ActionDispatch::ParamsParser.new(app)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#dispatch' do
|
||||
it 'provides webhook_request' do
|
||||
expect(controller_class).to receive(:dispatch).
|
||||
with(bot, hash_including('message'), instance_of(ActionDispatch::Request)).
|
||||
and_call_original
|
||||
dispatch_message :test
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
require 'action_dispatch'
|
||||
|
||||
RSpec.describe Telegram::Bot::UpdatesController::Testing do
|
||||
include_context 'telegram/bot/updates_controller'
|
||||
let(:controller_class) do
|
||||
@@ -24,4 +26,27 @@ RSpec.describe Telegram::Bot::UpdatesController::Testing do
|
||||
it { should_not change { controller.send(:session)[:key] }.from 'sval' }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#dispatch' do
|
||||
it 'doesn`t provide webhook_request' do
|
||||
dispatch
|
||||
expect(controller.webhook_request).to eq nil
|
||||
end
|
||||
|
||||
context 'when webhook_request is set' do
|
||||
let(:webhook_request) { ActionDispatch::Request.new({}) }
|
||||
it 'passes it to controller' do
|
||||
dispatch
|
||||
expect(controller.webhook_request).to eq webhook_request
|
||||
end
|
||||
end
|
||||
|
||||
context 'when webhook_request is given' do
|
||||
it 'passes it to controller' do
|
||||
webhook_request = ::ActionDispatch::Request.new({})
|
||||
dispatch(update, bot, webhook_request)
|
||||
expect(controller.webhook_request).to eq webhook_request
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Ссылка в новой задаче
Block a user