1
0
Fork 0

Paginate FederalSubjectsController#index

This commit is contained in:
Alex Kotov 2020-01-05 00:09:23 +05:00
parent d2917b6d98
commit 6846af8668
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
5 changed files with 15 additions and 1 deletions

View file

@ -1,12 +1,15 @@
# frozen_string_literal: true
class FederalSubjectsController < ApplicationController
include PaginalController
before_action :set_federal_subject, except: :index
# GET /federal_subjects
def index
authorize :federal_subject
@federal_subjects = policy_scope(FederalSubject).order_by_display_name
.page(active_page)
end
# GET /federal_subjects/:number

View file

@ -3,4 +3,5 @@
<%= render partial: 'table',
locals: { federal_subjects: @federal_subjects } %>
<%= pagination @federal_subjects %>
</div>

View file

@ -15,6 +15,7 @@ en:
many: Contact networks
federal_subject:
one: State
few: States
many: States
org_unit:
one: Organizational unit

View file

@ -15,6 +15,7 @@ ru:
many: Сети контактов
federal_subject:
one: Регион
few: Регионы
many: Регионы
org_unit:
one: Организационное подразделение

View file

@ -3,14 +3,22 @@
require 'rails_helper'
RSpec.describe 'GET /federal_subjects' do
let(:current_account) { create :superuser_account }
let :federal_subjects_count do
[0, 1, rand(2..4), rand(5..10), rand(20..40)].sample
end
before do
sign_in current_account.user if current_account&.user
create_list :federal_subject, rand(1..3)
create_list :federal_subject, federal_subjects_count
get '/federal_subjects'
end
it_behaves_like 'paginal controller', :federal_subjects_count
for_account_types nil, :usual, :superuser do
specify do
expect(response).to have_http_status :ok