Mount Sidekiq web interface
This commit is contained in:
parent
3511383384
commit
55e44b154d
2 changed files with 51 additions and 0 deletions
|
@ -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
|
||||
|
||||
|
|
43
spec/requests/staff/sidekiq/show_spec.rb
Normal file
43
spec/requests/staff/sidekiq/show_spec.rb
Normal 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
|
Reference in a new issue