Skip to content

Commit

Permalink
lowered pagination threshold in dev and staging using kaminari (#4865)
Browse files Browse the repository at this point in the history
* lowered pagination threshold in dev and staging using kaminari

* Trigger Build
  • Loading branch information
k8port authored Dec 19, 2024
1 parent a943f81 commit 05fa004
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
6 changes: 5 additions & 1 deletion config/initializers/kaminari_config.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# frozen_string_literal: true
Kaminari.configure do |config|
config.default_per_page = 50
if Rails.env.development? || Rails.env.staging?
config.default_per_page = 5
else
config.default_per_page = 50
end
# config.max_per_page = nil
# config.window = 4
# config.outer_window = 0
Expand Down
48 changes: 48 additions & 0 deletions spec/lib/kaminari_config_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require "rails_helper"

RSpec.describe "Kaminari configuration" do
describe "default_per_page setting" do
after(:each) do
# Reset Kaminari configuration after each test
Kaminari.configure do |config|
config.default_per_page = 50
end
end

context "in development environment" do
before do
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new("development"))
# Reload the configuration file
load Rails.root.join("config/initializers/kaminari_config.rb")
end

it "sets default_per_page to 5" do
expect(Kaminari.config.default_per_page).to eq(5)
end
end

context "in staging environment" do
before do
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new("staging"))
# Reload the configuration file
load Rails.root.join("config/initializers/kaminari_config.rb")
end

it "sets default_per_page to 5" do
expect(Kaminari.config.default_per_page).to eq(5)
end
end

context "in production environment" do
before do
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new("production"))
# Reload the configuration file
load Rails.root.join("config/initializers/kaminari_config.rb")
end

it "sets default_per_page to 50" do
expect(Kaminari.config.default_per_page).to eq(50)
end
end
end
end

0 comments on commit 05fa004

Please sign in to comment.