1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/spec/requests/telegram_bot_updates/create_spec.rb

43 lines
1 KiB
Ruby

# 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
end
end
context 'when no telegram bot exist' do
before do
post '/telegram_bot_updates',
params: { telegram_bot_id: rand(10_000..1_000_000),
secret: telegram_bot.secret }
end
specify do
expect(response).to have_http_status :not_found
end
end
context 'when secret is not valid' do
before do
post '/telegram_bot_updates',
params: { telegram_bot_id: telegram_bot.id,
secret: SecureRandom.hex }
end
specify do
expect(response).to have_http_status :unauthorized
end
end
end