Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lowered pagination threshold in dev and staging using kaminari #4865

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also think of making this configurable from env config? Does this makes sense here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true - we could move this to development.rb and staging.rb which is a bit neater. But I wouldn't block the PR for that.

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
Loading