зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-03 17:55:52 +03:00
Add UpdatesController#webhook_request
Этот коммит содержится в:
@@ -13,8 +13,9 @@ RSpec.shared_context 'telegram/bot/updates_controller' do
|
||||
x.extend Telegram::Bot::UpdatesController::Testing
|
||||
end
|
||||
end
|
||||
let(:controller_args) { [bot, deep_stringify(update)] }
|
||||
let(:controller_args) { [bot, deep_stringify(update), webhook_request] }
|
||||
let(:update) { {payload_type => payload} }
|
||||
let(:webhook_request) { nil }
|
||||
let(:payload_type) { :some_type }
|
||||
let(:payload) { double(:payload) }
|
||||
let(:bot) { Telegram::Bot::ClientStub.new(bot_name) }
|
||||
@@ -22,8 +23,8 @@ RSpec.shared_context 'telegram/bot/updates_controller' do
|
||||
let(:session) { controller.send(:session) }
|
||||
|
||||
# Process update.
|
||||
def dispatch(update = self.update, bot = self.bot)
|
||||
controller.dispatch_again(bot, deep_stringify(update))
|
||||
def dispatch(update = self.update, bot = self.bot, webhook_request = self.webhook_request)
|
||||
controller.dispatch_again(bot, deep_stringify(update), webhook_request)
|
||||
end
|
||||
|
||||
# Same as `.as_json` but mocks-friendly.
|
||||
|
||||
@@ -5,9 +5,9 @@ module Telegram
|
||||
IVARS_TO_KEEP = %i[@_session].freeze
|
||||
|
||||
# Perform multiple dispatches on same instance.
|
||||
def dispatch_again(bot = nil, update = nil)
|
||||
def dispatch_again(bot = nil, update = nil, webhook_request = nil)
|
||||
recycle!
|
||||
initialize(bot, update)
|
||||
initialize(bot, update, webhook_request)
|
||||
dispatch
|
||||
end
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ module Telegram
|
||||
# Include this module to type cast update to Virtus model
|
||||
# using `telegram-bot-types` gem (install this gem first).
|
||||
module TypedUpdate
|
||||
def initialize(bot = nil, update = nil)
|
||||
def initialize(bot = nil, update = nil, webhook_request = nil)
|
||||
update = Types::Update.new(update) if update && !update.is_a?(Types::Update)
|
||||
super
|
||||
end
|
||||
|
||||
Ссылка в новой задаче
Block a user