diff --git a/app/controllers/federal_subjects_controller.rb b/app/controllers/federal_subjects_controller.rb index 792b9ad..eeb4b91 100644 --- a/app/controllers/federal_subjects_controller.rb +++ b/app/controllers/federal_subjects_controller.rb @@ -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 diff --git a/app/views/federal_subjects/index.html.erb b/app/views/federal_subjects/index.html.erb index 5c93319..f4fa4c5 100644 --- a/app/views/federal_subjects/index.html.erb +++ b/app/views/federal_subjects/index.html.erb @@ -3,4 +3,5 @@ <%= render partial: 'table', locals: { federal_subjects: @federal_subjects } %> + <%= pagination @federal_subjects %> diff --git a/config/locales/activerecord/en.yml b/config/locales/activerecord/en.yml index 27e01ff..3216aa7 100644 --- a/config/locales/activerecord/en.yml +++ b/config/locales/activerecord/en.yml @@ -15,6 +15,7 @@ en: many: Contact networks federal_subject: one: State + few: States many: States org_unit: one: Organizational unit diff --git a/config/locales/activerecord/ru.yml b/config/locales/activerecord/ru.yml index c9916ce..1069c97 100644 --- a/config/locales/activerecord/ru.yml +++ b/config/locales/activerecord/ru.yml @@ -15,6 +15,7 @@ ru: many: Сети контактов federal_subject: one: Регион + few: Регионы many: Регионы org_unit: one: Организационное подразделение diff --git a/spec/requests/federal_subjects/index_spec.rb b/spec/requests/federal_subjects/index_spec.rb index d211d73..e7da262 100644 --- a/spec/requests/federal_subjects/index_spec.rb +++ b/spec/requests/federal_subjects/index_spec.rb @@ -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