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_bots/updates/create_spec.rb
2018-12-07 07:43:30 +05:00

40 lines
936 B
Ruby

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'POST /telegram_bots/:telegram_bot_id/updates' do
let(:telegram_bot) { create :telegram_bot }
context 'with valid params' do
before do
post "/telegram_bots/#{telegram_bot.id}/updates",
params: { 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_bots/#{rand(10_000..1_000_000)}/updates",
params: { 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_bots/#{telegram_bot.id}/updates",
params: { secret: SecureRandom.hex }
end
specify do
expect(response).to have_http_status :unauthorized
end
end
end