From 7d8a19d3c854084d34831f07c12f0ffe6ea94ae6 Mon Sep 17 00:00:00 2001 From: Max Melentiev Date: Sun, 13 Mar 2022 21:39:55 +0000 Subject: [PATCH] Pass action parameter to RequestBodyFormatter --- CHANGELOG.md | 2 +- README.md | 2 +- lib/telegram/bot/client.rb | 4 ++-- lib/telegram/bot/version.rb | 2 +- spec/telegram/bot/client_spec.rb | 3 ++- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c567bf2..b3f86a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Unreleased -# 0.15.5 +# 0.15.6 - Rails 7.0 support. - Fix sending File objects in nested objects in sendMediaGroup. diff --git a/README.md b/README.md index d37410b..010748b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Gem Version](https://badge.fury.io/rb/telegram-bot.svg)](http://badge.fury.io/rb/telegram-bot) [![Code Climate](https://codeclimate.com/github/telegram-bot-rb/telegram-bot/badges/gpa.svg)](https://codeclimate.com/github/telegram-bot-rb/telegram-bot) -[![Build Status](https://travis-ci.com/telegram-bot-rb/telegram-bot.svg)](https://travis-ci.com/telegram-bot-rb/telegram-bot) +[![Build Status](https://app.travis-ci.com/telegram-bot-rb/telegram-bot.svg)](https://app.travis-ci.com/github/telegram-bot-rb/telegram-bot) Tools for developing Telegram bots. Best used with Rails, but can be used in [standalone app](https://github.com/telegram-bot-rb/telegram-bot/wiki/Not-rails-application). diff --git a/lib/telegram/bot/client.rb b/lib/telegram/bot/client.rb index 3edb706..79e018f 100644 --- a/lib/telegram/bot/client.rb +++ b/lib/telegram/bot/client.rb @@ -37,7 +37,7 @@ module Telegram end def prepare_async_args(action, body = {}) - [action.to_s, Async.prepare_hash(RequestBodyFormatter.format(body))] + [action.to_s, Async.prepare_hash(RequestBodyFormatter.format(body, action))] end def error_for_response(response) @@ -63,7 +63,7 @@ module Telegram end def request(action, body = {}) - response = http_request("#{base_uri}#{action}", RequestBodyFormatter.format(body)) + response = http_request("#{base_uri}#{action}", RequestBodyFormatter.format(body, action)) raise self.class.error_for_response(response) if response.status >= 300 JSON.parse(response.body) end diff --git a/lib/telegram/bot/version.rb b/lib/telegram/bot/version.rb index 821ffee..7e0433d 100644 --- a/lib/telegram/bot/version.rb +++ b/lib/telegram/bot/version.rb @@ -1,6 +1,6 @@ module Telegram module Bot - VERSION = '0.15.5'.freeze + VERSION = '0.15.6'.freeze def self.gem_version Gem::Version.new VERSION diff --git a/spec/telegram/bot/client_spec.rb b/spec/telegram/bot/client_spec.rb index cca549d..e787ba0 100644 --- a/spec/telegram/bot/client_spec.rb +++ b/spec/telegram/bot/client_spec.rb @@ -129,7 +129,8 @@ RSpec.describe Telegram::Bot::Client do let(:body) { body_json.to_json } let(:body_json) { {'param' => 'val', 'description' => 'some description'} } before do - expect(described_class).to receive(:prepare_body).with(request_body) { prepared_body } + expect(Telegram::Bot::Client::RequestBodyFormatter). + to receive(:format).with(request_body, action) { prepared_body } expect(instance).to receive(:http_request).with(url, prepared_body) { response } end around { |ex| Telegram::Bot::ClientStub.stub_all!(false) { ex.run } }