1
0
Fork 0

Add action Staff::HomeController#show

This commit is contained in:
Alex Kotov 2019-03-27 08:02:51 +05:00
parent 58bb068b4f
commit 10655cf2f7
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
6 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,8 @@
# frozen_string_literal: true
class Staff::HomeController < ApplicationController
# GET /staff
def show
authorize %i[staff home]
end
end

View File

@ -0,0 +1,7 @@
# frozen_string_literal: true
class Staff::HomePolicy < ApplicationPolicy
def show?
account&.is_superuser?
end
end

View File

@ -0,0 +1,2 @@
<div class="container">
</div>

View File

@ -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

View 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

View 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