Add action Staff::HomeController#show
This commit is contained in:
parent
58bb068b4f
commit
10655cf2f7
6 changed files with 52 additions and 0 deletions
8
app/controllers/staff/home_controller.rb
Normal file
8
app/controllers/staff/home_controller.rb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Staff::HomeController < ApplicationController
|
||||||
|
# GET /staff
|
||||||
|
def show
|
||||||
|
authorize %i[staff home]
|
||||||
|
end
|
||||||
|
end
|
7
app/policies/staff/home_policy.rb
Normal file
7
app/policies/staff/home_policy.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Staff::HomePolicy < ApplicationPolicy
|
||||||
|
def show?
|
||||||
|
account&.is_superuser?
|
||||||
|
end
|
||||||
|
end
|
2
app/views/staff/home/show.html.erb
Normal file
2
app/views/staff/home/show.html.erb
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
<div class="container">
|
||||||
|
</div>
|
|
@ -44,6 +44,8 @@ Rails.application.routes.draw do
|
||||||
#########################
|
#########################
|
||||||
|
|
||||||
namespace :staff do
|
namespace :staff do
|
||||||
|
root to: 'home#show'
|
||||||
|
|
||||||
authenticate :user,
|
authenticate :user,
|
||||||
->(user) { user.account.can_access_sidekiq_web_interface? } do
|
->(user) { user.account.can_access_sidekiq_web_interface? } do
|
||||||
mount Sidekiq::Web, at: '/sidekiq', as: :sidekiq
|
mount Sidekiq::Web, at: '/sidekiq', as: :sidekiq
|
||||||
|
|
7
spec/policies/staff/home_policy_spec.rb
Normal file
7
spec/policies/staff/home_policy_spec.rb
Normal file
|
@ -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
|
26
spec/requests/staff/root_spec.rb
Normal file
26
spec/requests/staff/root_spec.rb
Normal file
|
@ -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 a new issue