Add action Staff::HomeController#show
This commit is contained in:
parent
58bb068b4f
commit
10655cf2f7
|
@ -0,0 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Staff::HomeController < ApplicationController
|
||||
# GET /staff
|
||||
def show
|
||||
authorize %i[staff home]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Staff::HomePolicy < ApplicationPolicy
|
||||
def show?
|
||||
account&.is_superuser?
|
||||
end
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
<div class="container">
|
||||
</div>
|
|
@ -44,6 +44,8 @@ Rails.application.routes.draw do
|
|||
#########################
|
||||
|
||||
namespace :staff do
|
||||
root to: 'home#show'
|
||||
|
||||
authenticate :user,
|
||||
->(user) { user.account.can_access_sidekiq_web_interface? } do
|
||||
mount Sidekiq::Web, at: '/sidekiq', as: :sidekiq
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Staff::HomePolicy do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
|
@ -0,0 +1,26 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'GET /staff' do
|
||||
def make_request
|
||||
get '/staff'
|
||||
end
|
||||
|
||||
before do
|
||||
sign_in current_account.user if current_account&.user
|
||||
make_request
|
||||
end
|
||||
|
||||
for_account_types nil, :guest, :usual do
|
||||
specify do
|
||||
expect(response).to have_http_status :forbidden
|
||||
end
|
||||
end
|
||||
|
||||
for_account_types :superuser do
|
||||
specify do
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue