1
0
Fork 0

Mount Sidekiq web interface

This commit is contained in:
Alex Kotov 2018-12-12 08:08:42 +05:00
parent 3511383384
commit 55e44b154d
No known key found for this signature in database
GPG key ID: 4E831250F47DE154
2 changed files with 51 additions and 0 deletions

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
require 'sidekiq/web'
Rails.application.routes.draw do
root to: 'home#show'
@ -25,6 +27,12 @@ Rails.application.routes.draw do
end
namespace :staff do
authenticate :user, ->(user) { user.account.is_superuser? } do
mount Sidekiq::Web, at: '/sidekiq', as: :sidekiq
end
get '/sidekiq', to: redirect('/', status: 307), as: :forbidden_sidekiq
resources :telegram_chats, only: %i[index show]
end

View file

@ -0,0 +1,43 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'GET /staff/sidekiq' do
before do
@new_user_session_url = new_user_session_url
sign_in current_account.user if current_account&.user
get '/staff/sidekiq'
end
context 'when no account is authenticated' do
let(:current_account) { nil }
specify do
expect(response).to redirect_to @new_user_session_url
end
end
context 'when guest account is authenticated' do
let(:current_account) { create :guest_account }
specify do
expect(response).to redirect_to @new_user_session_url
end
end
context 'when usual account is authenticated' do
let(:current_account) { create :usual_account }
specify do
expect(response).to redirect_to root_url
end
end
context 'when superuser account is authenticated' do
let(:current_account) { create :superuser_account }
specify do
expect(response).to have_http_status :ok
end
end
end