From 7045a71d8b1a8a41bd51dcce746049ddc69f0017 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Tue, 12 Dec 2017 13:09:04 -0800 Subject: [PATCH 1/3] Bump kaminari requirement to ~> 1.1 --- api/solidus_api.gemspec | 2 +- backend/solidus_backend.gemspec | 2 +- core/solidus_core.gemspec | 2 +- frontend/solidus_frontend.gemspec | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/solidus_api.gemspec b/api/solidus_api.gemspec index f49defdf6f0..f5a835450c3 100644 --- a/api/solidus_api.gemspec +++ b/api/solidus_api.gemspec @@ -23,5 +23,5 @@ Gem::Specification.new do |gem| gem.add_dependency 'solidus_core', gem.version gem.add_dependency 'responders' gem.add_dependency 'jbuilder', '~> 2.6' - gem.add_dependency 'kaminari', '>= 0.17', '< 2.0' + gem.add_dependency 'kaminari', '~> 1.1' end diff --git a/backend/solidus_backend.gemspec b/backend/solidus_backend.gemspec index 432d6199d54..c2814c61696 100644 --- a/backend/solidus_backend.gemspec +++ b/backend/solidus_backend.gemspec @@ -29,7 +29,7 @@ Gem::Specification.new do |s| s.add_dependency 'jquery-rails' s.add_dependency 'jquery-ui-rails', '~> 5.0.0' s.add_dependency 'font-awesome-rails', '~> 4.0' - s.add_dependency 'kaminari', '>= 0.17', '< 2.0' + s.add_dependency 'kaminari', '~> 1.1' s.add_dependency 'jbuilder', '~> 2.6' s.add_dependency 'handlebars_assets', '~> 0.23' diff --git a/core/solidus_core.gemspec b/core/solidus_core.gemspec index 198bb4ac2df..8c0286f09f0 100644 --- a/core/solidus_core.gemspec +++ b/core/solidus_core.gemspec @@ -32,7 +32,7 @@ Gem::Specification.new do |s| s.add_dependency 'carmen', '~> 1.1.0' s.add_dependency 'cancancan', '~> 1.10' s.add_dependency 'friendly_id', '~> 5.0' - s.add_dependency 'kaminari', '>= 0.17', '< 2.0' + s.add_dependency 'kaminari', '~> 1.1' s.add_dependency 'monetize', '~> 1.1' s.add_dependency 'paperclip', ['>= 4.2', '< 6'] s.add_dependency 'paranoia', '~> 2.4' diff --git a/frontend/solidus_frontend.gemspec b/frontend/solidus_frontend.gemspec index 8a8837f32c2..89fabb7eae5 100644 --- a/frontend/solidus_frontend.gemspec +++ b/frontend/solidus_frontend.gemspec @@ -28,7 +28,7 @@ Gem::Specification.new do |s| s.add_dependency 'sass-rails' s.add_dependency 'font-awesome-rails', '~> 4.0' s.add_dependency 'truncate_html', '~> 0.9', '>= 0.9.2' - s.add_dependency 'kaminari', '>= 0.17', '< 2.0' + s.add_dependency 'kaminari', '~> 1.1' s.add_development_dependency 'capybara-accessible' end From f421d5a7f1f07615faa2e6663488b030414382c8 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Tue, 12 Dec 2017 13:09:45 -0800 Subject: [PATCH 2/3] Only require kaminari-activerecord in core and api As of 1.0, kaminari has split up activerecord from actionview functionality. We might as well require only what we need in core. --- api/solidus_api.gemspec | 2 +- backend/lib/spree/backend.rb | 1 + core/lib/spree/core.rb | 2 +- core/solidus_core.gemspec | 2 +- frontend/lib/spree/frontend.rb | 1 + 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/api/solidus_api.gemspec b/api/solidus_api.gemspec index f5a835450c3..cd1454560bd 100644 --- a/api/solidus_api.gemspec +++ b/api/solidus_api.gemspec @@ -23,5 +23,5 @@ Gem::Specification.new do |gem| gem.add_dependency 'solidus_core', gem.version gem.add_dependency 'responders' gem.add_dependency 'jbuilder', '~> 2.6' - gem.add_dependency 'kaminari', '~> 1.1' + gem.add_dependency 'kaminari-activerecord', '~> 1.1' end diff --git a/backend/lib/spree/backend.rb b/backend/lib/spree/backend.rb index 25da78fd501..cc859654ecb 100644 --- a/backend/lib/spree/backend.rb +++ b/backend/lib/spree/backend.rb @@ -8,6 +8,7 @@ require 'font-awesome-rails' require 'autoprefixer-rails' require 'jbuilder' +require 'kaminari' require 'spree_core' require 'spree_api' diff --git a/core/lib/spree/core.rb b/core/lib/spree/core.rb index 10b01fdbcff..6aa121a5482 100644 --- a/core/lib/spree/core.rb +++ b/core/lib/spree/core.rb @@ -3,7 +3,7 @@ require 'awesome_nested_set' require 'cancan' require 'friendly_id' -require 'kaminari' +require 'kaminari/activerecord' require 'mail' require 'monetize' require 'paperclip' diff --git a/core/solidus_core.gemspec b/core/solidus_core.gemspec index 8c0286f09f0..c836247df20 100644 --- a/core/solidus_core.gemspec +++ b/core/solidus_core.gemspec @@ -32,7 +32,7 @@ Gem::Specification.new do |s| s.add_dependency 'carmen', '~> 1.1.0' s.add_dependency 'cancancan', '~> 1.10' s.add_dependency 'friendly_id', '~> 5.0' - s.add_dependency 'kaminari', '~> 1.1' + s.add_dependency 'kaminari-activerecord', '~> 1.1' s.add_dependency 'monetize', '~> 1.1' s.add_dependency 'paperclip', ['>= 4.2', '< 6'] s.add_dependency 'paranoia', '~> 2.4' diff --git a/frontend/lib/spree/frontend.rb b/frontend/lib/spree/frontend.rb index 537fbbb3fcc..b6c05dba2ab 100644 --- a/frontend/lib/spree/frontend.rb +++ b/frontend/lib/spree/frontend.rb @@ -4,6 +4,7 @@ require 'sass-rails' require 'font-awesome-rails' require 'responders' +require 'kaminari' require 'solidus_core' require 'solidus_api' From f8b54cfb0bc93fabf8ef188ddb9c73426764963b Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Tue, 12 Dec 2017 13:19:03 -0800 Subject: [PATCH 3/3] Use kaminari's current_per_page This is cleaner than checking limit_value --- api/app/views/spree/api/shared/_pagination.json.jbuilder | 2 +- backend/spec/controllers/spree/admin/orders_controller_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/app/views/spree/api/shared/_pagination.json.jbuilder b/api/app/views/spree/api/shared/_pagination.json.jbuilder index 153b3abb93e..f30f706ae5a 100644 --- a/api/app/views/spree/api/shared/_pagination.json.jbuilder +++ b/api/app/views/spree/api/shared/_pagination.json.jbuilder @@ -2,4 +2,4 @@ json.count pagination.count json.total_count pagination.total_count json.current_page pagination.current_page json.pages pagination.total_pages -json.per_page pagination.limit_value +json.per_page pagination.current_per_page diff --git a/backend/spec/controllers/spree/admin/orders_controller_spec.rb b/backend/spec/controllers/spree/admin/orders_controller_spec.rb index 4ef7b69d503..6e6964ce2fb 100644 --- a/backend/spec/controllers/spree/admin/orders_controller_spec.rb +++ b/backend/spec/controllers/spree/admin/orders_controller_spec.rb @@ -68,7 +68,7 @@ it "can page through the orders" do get :index, params: { page: 2, per_page: 10 } expect(assigns[:orders].offset_value).to eq(10) - expect(assigns[:orders].limit_value).to eq(10) + expect(assigns[:orders].current_per_page).to eq(10) end end