Paginate Staffs::AccountsController#index
This commit is contained in:
parent
a1b074bf7e
commit
cdf40373fa
5 changed files with 51 additions and 4 deletions
|
@ -9,7 +9,7 @@ class Staffs::AccountsController < ApplicationController
|
|||
@accounts = policy_scope(
|
||||
Account,
|
||||
policy_scope_class: Staff::AccountPolicy::Scope,
|
||||
)
|
||||
).page(params[:page])
|
||||
end
|
||||
|
||||
# GET /staff/accounts/:nickname
|
||||
|
|
|
@ -5,4 +5,5 @@
|
|||
) %>
|
||||
|
||||
<%= render partial: 'table', locals: { accounts: @accounts } %>
|
||||
<%= pagination @accounts %>
|
||||
</div>
|
||||
|
|
|
@ -3,6 +3,7 @@ en:
|
|||
models:
|
||||
account:
|
||||
one: Account
|
||||
few: Accounts
|
||||
many: Accounts
|
||||
contact:
|
||||
one: Contact
|
||||
|
|
|
@ -3,6 +3,7 @@ ru:
|
|||
models:
|
||||
account:
|
||||
one: Аккаунт
|
||||
few: Аккаунты
|
||||
many: Аккаунты
|
||||
contact:
|
||||
one: Контакт
|
||||
|
|
|
@ -3,12 +3,16 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'GET /staff/accounts' do
|
||||
let(:current_account) { create :superuser_account }
|
||||
|
||||
let :accounts_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 :usual_account
|
||||
create :personal_account
|
||||
create :superuser_account
|
||||
create_list :personal_account, accounts_count
|
||||
|
||||
get '/staff/accounts'
|
||||
end
|
||||
|
@ -24,4 +28,44 @@ RSpec.describe 'GET /staff/accounts' do
|
|||
expect(response).to have_http_status :ok
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there are no accounts' do
|
||||
let(:accounts_count) { 0 }
|
||||
|
||||
specify do
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there is one account' do
|
||||
let(:accounts_count) { 1 }
|
||||
|
||||
specify do
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there are few accounts' do
|
||||
let(:accounts_count) { rand 2..4 }
|
||||
|
||||
specify do
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there are many accounts' do
|
||||
let(:accounts_count) { rand 5..10 }
|
||||
|
||||
specify do
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there are lot of accounts' do
|
||||
let(:accounts_count) { rand 20..40 }
|
||||
|
||||
specify do
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Reference in a new issue