Add Staff::MembershipAppsController
This commit is contained in:
parent
6d7bcd0c24
commit
84ae1cdce3
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Staff::MembershipAppsController < ApplicationController
|
||||
before_action :set_membership_app, except: :index
|
||||
|
||||
# GET /membership_apps
|
||||
def index
|
||||
authorize %i[staff membership_app]
|
||||
@membership_apps = policy_scope(
|
||||
MembershipApp,
|
||||
policy_scope_class: Staff::MembershipAppPolicy::Scope,
|
||||
)
|
||||
end
|
||||
|
||||
# GET /membership_apps/:id
|
||||
def show
|
||||
authorize [:staff, @membership_app]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_membership_app
|
||||
@membership_app = MembershipApp.find params[:id]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,40 @@
|
|||
<div class="container">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
<%= MembershipApp.human_attribute_name :id %>
|
||||
</th>
|
||||
<th scope="col">
|
||||
<%= MembershipApp.human_attribute_name :last_name %>
|
||||
</th>
|
||||
<th scope="col">
|
||||
<%= MembershipApp.human_attribute_name :first_name %>
|
||||
</th>
|
||||
<th scope="col">
|
||||
<%= MembershipApp.human_attribute_name :middle_name %>
|
||||
</th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @membership_apps.each do |membership_app| %>
|
||||
<tr>
|
||||
<td scope="row"><%= membership_app.id %></td>
|
||||
<td><%= truncate membership_app.last_name, length: 20 %></td>
|
||||
<td><%= truncate membership_app.first_name, length: 20 %></td>
|
||||
<td><%= truncate membership_app.middle_name, length: 20 %></td>
|
||||
<td>
|
||||
<% if policy([:staff, membership_app]).show? %>
|
||||
<%= link_to [:staff, membership_app],
|
||||
role: :button, class: 'btn btn-light btn-sm' do %>
|
||||
<i class="far fa-eye"></i>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
|
@ -0,0 +1,12 @@
|
|||
<div class="container">
|
||||
<dl>
|
||||
<dt><%= MembershipApp.human_attribute_name :last_name %></dt>
|
||||
<dd><%= truncate @membership_app.last_name %></dd>
|
||||
|
||||
<dt><%= MembershipApp.human_attribute_name :first_name %></dt>
|
||||
<dd><%= truncate @membership_app.first_name %></dd>
|
||||
|
||||
<dt><%= MembershipApp.human_attribute_name :middle_name %></dt>
|
||||
<dd><%= truncate @membership_app.middle_name %></dd>
|
||||
</dl>
|
||||
</div>
|
|
@ -60,6 +60,7 @@ Rails.application.routes.draw do
|
|||
only: %i[index create]
|
||||
end
|
||||
|
||||
resources :membership_apps, only: %i[index show]
|
||||
resources :telegram_bots, only: %i[index show]
|
||||
resources :telegram_chats, only: %i[index show]
|
||||
end
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'GET /staff/membership_apps' do
|
||||
before do
|
||||
sign_in current_account.user if current_account&.user
|
||||
|
||||
create_list :membership_app, 5
|
||||
|
||||
get '/staff/membership_apps'
|
||||
end
|
||||
|
||||
for_account_types nil, :guest, :usual do
|
||||
specify do
|
||||
expect(response).to have_http_status :unauthorized
|
||||
end
|
||||
end
|
||||
|
||||
for_account_types :superuser do
|
||||
specify do
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,24 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'GET /staff/membership_apps/:id' do
|
||||
let!(:membership_app) { create :membership_app }
|
||||
|
||||
before do
|
||||
sign_in current_account.user if current_account&.user
|
||||
get "/staff/membership_apps/#{membership_app.id}"
|
||||
end
|
||||
|
||||
for_account_types nil, :guest, :usual do
|
||||
specify do
|
||||
expect(response).to have_http_status :unauthorized
|
||||
end
|
||||
end
|
||||
|
||||
for_account_types :superuser do
|
||||
specify do
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue