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(
|
@accounts = policy_scope(
|
||||||
Account,
|
Account,
|
||||||
policy_scope_class: Staff::AccountPolicy::Scope,
|
policy_scope_class: Staff::AccountPolicy::Scope,
|
||||||
)
|
).page(params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /staff/accounts/:nickname
|
# GET /staff/accounts/:nickname
|
||||||
|
|
|
@ -5,4 +5,5 @@
|
||||||
) %>
|
) %>
|
||||||
|
|
||||||
<%= render partial: 'table', locals: { accounts: @accounts } %>
|
<%= render partial: 'table', locals: { accounts: @accounts } %>
|
||||||
|
<%= pagination @accounts %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,6 +3,7 @@ en:
|
||||||
models:
|
models:
|
||||||
account:
|
account:
|
||||||
one: Account
|
one: Account
|
||||||
|
few: Accounts
|
||||||
many: Accounts
|
many: Accounts
|
||||||
contact:
|
contact:
|
||||||
one: Contact
|
one: Contact
|
||||||
|
|
|
@ -3,6 +3,7 @@ ru:
|
||||||
models:
|
models:
|
||||||
account:
|
account:
|
||||||
one: Аккаунт
|
one: Аккаунт
|
||||||
|
few: Аккаунты
|
||||||
many: Аккаунты
|
many: Аккаунты
|
||||||
contact:
|
contact:
|
||||||
one: Контакт
|
one: Контакт
|
||||||
|
|
|
@ -3,12 +3,16 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'GET /staff/accounts' do
|
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
|
before do
|
||||||
sign_in current_account.user if current_account&.user
|
sign_in current_account.user if current_account&.user
|
||||||
|
|
||||||
create :usual_account
|
create_list :personal_account, accounts_count
|
||||||
create :personal_account
|
|
||||||
create :superuser_account
|
|
||||||
|
|
||||||
get '/staff/accounts'
|
get '/staff/accounts'
|
||||||
end
|
end
|
||||||
|
@ -24,4 +28,44 @@ RSpec.describe 'GET /staff/accounts' do
|
||||||
expect(response).to have_http_status :ok
|
expect(response).to have_http_status :ok
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Reference in a new issue