Remove will paginate
This commit is contained in:
parent
f983fc3ea3
commit
62d8381ef7
10 changed files with 13 additions and 21 deletions
1
Gemfile
1
Gemfile
|
@ -33,7 +33,6 @@ gem 'haml-rails'
|
||||||
gem 'bootstrap-sass', '~> 3.3.5'
|
gem 'bootstrap-sass', '~> 3.3.5'
|
||||||
|
|
||||||
# Pagination
|
# Pagination
|
||||||
gem 'will_paginate-bootstrap'
|
|
||||||
gem 'kaminari'
|
gem 'kaminari'
|
||||||
|
|
||||||
# Decorators
|
# Decorators
|
||||||
|
|
|
@ -682,9 +682,6 @@ GEM
|
||||||
websocket-driver (0.6.5)
|
websocket-driver (0.6.5)
|
||||||
websocket-extensions (>= 0.1.0)
|
websocket-extensions (>= 0.1.0)
|
||||||
websocket-extensions (0.1.2)
|
websocket-extensions (0.1.2)
|
||||||
will_paginate (3.1.5)
|
|
||||||
will_paginate-bootstrap (1.0.1)
|
|
||||||
will_paginate (>= 3.0.3)
|
|
||||||
xml-simple (1.1.5)
|
xml-simple (1.1.5)
|
||||||
xpath (2.1.0)
|
xpath (2.1.0)
|
||||||
nokogiri (~> 1.3)
|
nokogiri (~> 1.3)
|
||||||
|
@ -779,7 +776,6 @@ DEPENDENCIES
|
||||||
vcr
|
vcr
|
||||||
web-console
|
web-console
|
||||||
webmock
|
webmock
|
||||||
will_paginate-bootstrap
|
|
||||||
xray-rails
|
xray-rails
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
|
|
|
@ -7,7 +7,7 @@ class API::V1::DossiersController < APIController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
procedure = current_administrateur.procedures.find(params[:procedure_id])
|
procedure = current_administrateur.procedures.find(params[:procedure_id])
|
||||||
dossiers = procedure.dossiers.state_not_brouillon.paginate(page: params[:page])
|
dossiers = procedure.dossiers.state_not_brouillon.page(params[:page]).per(per_page)
|
||||||
|
|
||||||
render json: { dossiers: dossiers.map{ |dossier| DossiersSerializer.new(dossier) }, pagination: pagination(dossiers) }, status: 200
|
render json: { dossiers: dossiers.map{ |dossier| DossiersSerializer.new(dossier) }, pagination: pagination(dossiers) }, status: 200
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
@ -35,8 +35,12 @@ class API::V1::DossiersController < APIController
|
||||||
def pagination(dossiers)
|
def pagination(dossiers)
|
||||||
{
|
{
|
||||||
page: dossiers.current_page,
|
page: dossiers.current_page,
|
||||||
resultats_par_page: dossiers.per_page,
|
resultats_par_page: dossiers.limit_value,
|
||||||
nombre_de_page: dossiers.total_pages
|
nombre_de_page: dossiers.total_pages
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def per_page # inherited value from will_paginate
|
||||||
|
12
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class DossierDecorator < Draper::Decorator
|
class DossierDecorator < Draper::Decorator
|
||||||
include Rails.application.routes.url_helpers
|
include Rails.application.routes.url_helpers
|
||||||
|
|
||||||
delegate :current_page, :per_page, :offset, :total_entries, :total_pages
|
delegate :current_page, :limit_value, :total_pages
|
||||||
delegate_all
|
delegate_all
|
||||||
|
|
||||||
def first_creation
|
def first_creation
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
class DossiersDecorator < Draper::CollectionDecorator
|
class DossiersDecorator < Draper::CollectionDecorator
|
||||||
delegate :current_page, :per_page, :offset, :total_entries, :total_pages
|
delegate :current_page, :limit_value, :total_pages
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
class ProceduresDecorator < Draper::CollectionDecorator
|
class ProceduresDecorator < Draper::CollectionDecorator
|
||||||
delegate :current_page, :per_page, :offset, :total_entries, :total_pages
|
delegate :current_page, :limit_value, :total_pages
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
require 'will_paginate'
|
|
||||||
|
|
||||||
WillPaginate.per_page = 12
|
|
|
@ -26,9 +26,6 @@ fr:
|
||||||
no-commentaires: "Il n'y a aucun message dans le fil de discussion, n'hésitez pas à initier le premier."
|
no-commentaires: "Il n'y a aucun message dans le fil de discussion, n'hésitez pas à initier le premier."
|
||||||
depositaire: "Dépositaire"
|
depositaire: "Dépositaire"
|
||||||
pieces: "Pièces jointes"
|
pieces: "Pièces jointes"
|
||||||
will_paginate:
|
|
||||||
next_label: 'Suivant'
|
|
||||||
previous_label: 'Précédent'
|
|
||||||
views:
|
views:
|
||||||
pagination:
|
pagination:
|
||||||
next: Suivant
|
next: Suivant
|
||||||
|
|
|
@ -65,7 +65,7 @@ describe API::V1::DossiersController do
|
||||||
let!(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') }
|
let!(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(Dossier).to receive(:per_page).and_return(1)
|
allow(controller).to receive(:per_page).and_return(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'pagination' do
|
describe 'pagination' do
|
||||||
|
|
|
@ -7,13 +7,12 @@ describe ProceduresDecorator do
|
||||||
create(:procedure, :published, created_at: Time.new(2015, 12, 24, 14, 10))
|
create(:procedure, :published, created_at: Time.new(2015, 12, 24, 14, 10))
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:procedure) { Procedure.all.paginate(page: 1) }
|
let(:procedure) { Procedure.all.page(1) }
|
||||||
|
|
||||||
subject { procedure.decorate }
|
subject { procedure.decorate }
|
||||||
|
|
||||||
it { expect(subject.current_page).not_to be_nil }
|
it { expect(subject.current_page).not_to be_nil }
|
||||||
it { expect(subject.per_page).not_to be_nil }
|
it { expect(subject.limit_value).not_to be_nil }
|
||||||
it { expect(subject.offset).not_to be_nil }
|
it { expect(subject.count).to eq(3) }
|
||||||
it { expect(subject.total_entries).not_to be_nil }
|
|
||||||
it { expect(subject.total_pages).not_to be_nil }
|
it { expect(subject.total_pages).not_to be_nil }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue