# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'POST /telegram_bot_updates' do
let(:telegram_bot) { create :telegram_bot }
context 'with valid params' do
before do
post '/telegram_bot_updates',
params: { telegram_bot_id: telegram_bot.id,
secret: telegram_bot.secret }
end
specify do
expect(response).to have_http_status :no_content
context 'when no telegram bot exist' do
params: { telegram_bot_id: rand(10_000..1_000_000),
expect(response).to have_http_status :not_found
context 'when secret is not valid' do
secret: SecureRandom.hex }
expect(response).to have_http_status :unauthorized