Paginate FederalSubjectsController#index
This commit is contained in:
parent
d2917b6d98
commit
6846af8668
5 changed files with 15 additions and 1 deletions
|
@ -1,12 +1,15 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class FederalSubjectsController < ApplicationController
|
class FederalSubjectsController < ApplicationController
|
||||||
|
include PaginalController
|
||||||
|
|
||||||
before_action :set_federal_subject, except: :index
|
before_action :set_federal_subject, except: :index
|
||||||
|
|
||||||
# GET /federal_subjects
|
# GET /federal_subjects
|
||||||
def index
|
def index
|
||||||
authorize :federal_subject
|
authorize :federal_subject
|
||||||
@federal_subjects = policy_scope(FederalSubject).order_by_display_name
|
@federal_subjects = policy_scope(FederalSubject).order_by_display_name
|
||||||
|
.page(active_page)
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /federal_subjects/:number
|
# GET /federal_subjects/:number
|
||||||
|
|
|
@ -3,4 +3,5 @@
|
||||||
|
|
||||||
<%= render partial: 'table',
|
<%= render partial: 'table',
|
||||||
locals: { federal_subjects: @federal_subjects } %>
|
locals: { federal_subjects: @federal_subjects } %>
|
||||||
|
<%= pagination @federal_subjects %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -15,6 +15,7 @@ en:
|
||||||
many: Contact networks
|
many: Contact networks
|
||||||
federal_subject:
|
federal_subject:
|
||||||
one: State
|
one: State
|
||||||
|
few: States
|
||||||
many: States
|
many: States
|
||||||
org_unit:
|
org_unit:
|
||||||
one: Organizational unit
|
one: Organizational unit
|
||||||
|
|
|
@ -15,6 +15,7 @@ ru:
|
||||||
many: Сети контактов
|
many: Сети контактов
|
||||||
federal_subject:
|
federal_subject:
|
||||||
one: Регион
|
one: Регион
|
||||||
|
few: Регионы
|
||||||
many: Регионы
|
many: Регионы
|
||||||
org_unit:
|
org_unit:
|
||||||
one: Организационное подразделение
|
one: Организационное подразделение
|
||||||
|
|
|
@ -3,14 +3,22 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'GET /federal_subjects' do
|
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
|
before do
|
||||||
sign_in current_account.user if current_account&.user
|
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'
|
get '/federal_subjects'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it_behaves_like 'paginal controller', :federal_subjects_count
|
||||||
|
|
||||||
for_account_types nil, :usual, :superuser do
|
for_account_types nil, :usual, :superuser do
|
||||||
specify do
|
specify do
|
||||||
expect(response).to have_http_status :ok
|
expect(response).to have_http_status :ok
|
||||||
|
|
Reference in a new issue