Reduce number of records in pagination tests
Creating more than 25 records isn't necessary to test pagination; we can stub the number of records per page in a test. On my machine we save about one second per test with these changes.
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
module ModerateActions
|
module ModerateActions
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
include Polymorphic
|
include Polymorphic
|
||||||
|
PER_PAGE = 50
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@resources = @resources.send(@current_filter)
|
@resources = @resources.send(@current_filter)
|
||||||
.send("sort_by_#{@current_order}")
|
.send("sort_by_#{@current_order}")
|
||||||
.page(params[:page])
|
.page(params[:page])
|
||||||
.per(50)
|
.per(PER_PAGE)
|
||||||
set_resources_instance
|
set_resources_instance
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1543,7 +1543,7 @@ describe "Admin budget investments" do
|
|||||||
before { selected_bi.update(cached_votes_up: 50) }
|
before { selected_bi.update(cached_votes_up: 50) }
|
||||||
|
|
||||||
scenario "After unselecting an investment", :js do
|
scenario "After unselecting an investment", :js do
|
||||||
create_list(:budget_investment, 30, budget: budget)
|
allow(Budget::Investment).to receive(:default_per_page).and_return(3)
|
||||||
|
|
||||||
visit admin_budget_budget_investments_path(budget)
|
visit admin_budget_budget_investments_path(budget)
|
||||||
|
|
||||||
|
|||||||
@@ -90,8 +90,8 @@ describe "Admin hidden budget investments" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Action links remember the pagination setting and the filter" do
|
scenario "Action links remember the pagination setting and the filter" do
|
||||||
per_page = Kaminari.config.default_per_page
|
allow(Budget::Investment).to receive(:default_per_page).and_return(2)
|
||||||
(per_page + 2).times { create(:budget_investment, :hidden, :with_confirmed_hide, heading: heading) }
|
4.times { create(:budget_investment, :hidden, :with_confirmed_hide, heading: heading) }
|
||||||
|
|
||||||
visit admin_hidden_budget_investments_path(filter: "with_confirmed_hide", page: 2)
|
visit admin_hidden_budget_investments_path(filter: "with_confirmed_hide", page: 2)
|
||||||
|
|
||||||
|
|||||||
@@ -125,8 +125,8 @@ describe "Admin hidden comments" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Action links remember the pagination setting and the filter" do
|
scenario "Action links remember the pagination setting and the filter" do
|
||||||
per_page = Kaminari.config.default_per_page
|
allow(Comment).to receive(:default_per_page).and_return(2)
|
||||||
(per_page + 2).times { create(:comment, :hidden, :with_confirmed_hide) }
|
4.times { create(:comment, :hidden, :with_confirmed_hide) }
|
||||||
|
|
||||||
visit admin_hidden_comments_path(filter: "with_confirmed_hide", page: 2)
|
visit admin_hidden_comments_path(filter: "with_confirmed_hide", page: 2)
|
||||||
|
|
||||||
|
|||||||
@@ -77,8 +77,8 @@ describe "Admin hidden debates" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Action links remember the pagination setting and the filter" do
|
scenario "Action links remember the pagination setting and the filter" do
|
||||||
per_page = Kaminari.config.default_per_page
|
allow(Debate).to receive(:default_per_page).and_return(2)
|
||||||
(per_page + 2).times { create(:debate, :hidden, :with_confirmed_hide) }
|
4.times { create(:debate, :hidden, :with_confirmed_hide) }
|
||||||
|
|
||||||
visit admin_hidden_debates_path(filter: "with_confirmed_hide", page: 2)
|
visit admin_hidden_debates_path(filter: "with_confirmed_hide", page: 2)
|
||||||
|
|
||||||
|
|||||||
@@ -89,8 +89,8 @@ describe "Admin hidden proposals" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Action links remember the pagination setting and the filter" do
|
scenario "Action links remember the pagination setting and the filter" do
|
||||||
per_page = Kaminari.config.default_per_page
|
allow(Proposal).to receive(:default_per_page).and_return(2)
|
||||||
(per_page + 2).times { create(:proposal, :hidden, :with_confirmed_hide) }
|
4.times { create(:proposal, :hidden, :with_confirmed_hide) }
|
||||||
|
|
||||||
visit admin_hidden_proposals_path(filter: "with_confirmed_hide", page: 2)
|
visit admin_hidden_proposals_path(filter: "with_confirmed_hide", page: 2)
|
||||||
|
|
||||||
|
|||||||
@@ -82,8 +82,8 @@ describe "Admin hidden users" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Action links remember the pagination setting and the filter" do
|
scenario "Action links remember the pagination setting and the filter" do
|
||||||
per_page = Kaminari.config.default_per_page
|
allow(User).to receive(:default_per_page).and_return(2)
|
||||||
(per_page + 2).times { create(:user, :hidden, :with_confirmed_hide) }
|
4.times { create(:user, :hidden, :with_confirmed_hide) }
|
||||||
|
|
||||||
visit admin_hidden_users_path(filter: "with_confirmed_hide", page: 2)
|
visit admin_hidden_users_path(filter: "with_confirmed_hide", page: 2)
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ describe "Admin local census records" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Should show paginator" do
|
scenario "Should show paginator" do
|
||||||
create_list(:local_census_record, 25)
|
allow(LocalCensusRecord).to receive(:default_per_page).and_return(3)
|
||||||
|
create_list(:local_census_record, 3)
|
||||||
visit admin_local_census_records_path
|
visit admin_local_census_records_path
|
||||||
|
|
||||||
within ".pagination" do
|
within ".pagination" do
|
||||||
|
|||||||
@@ -202,9 +202,9 @@ describe "Admin::Organizations" do
|
|||||||
expect(page).not_to have_content("Verified Organization")
|
expect(page).not_to have_content("Verified Organization")
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Verifying organization links remember the pagination setting and the filter" do
|
scenario "Verifying organization links remembers parameters " do
|
||||||
per_page = Kaminari.config.default_per_page
|
allow(Organization).to receive(:default_per_page).and_return(2)
|
||||||
(per_page + 2).times { create(:organization) }
|
4.times { create(:organization) }
|
||||||
|
|
||||||
visit admin_organizations_path(filter: "pending", page: 2)
|
visit admin_organizations_path(filter: "pending", page: 2)
|
||||||
|
|
||||||
|
|||||||
@@ -80,8 +80,8 @@ describe "Admin proposal notifications" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Action links remember the pagination setting and the filter" do
|
scenario "Action links remember the pagination setting and the filter" do
|
||||||
per_page = Kaminari.config.default_per_page
|
allow(ProposalNotification).to receive(:default_per_page).and_return(2)
|
||||||
(per_page + 2).times { create(:proposal_notification, :hidden, :with_confirmed_hide) }
|
4.times { create(:proposal_notification, :hidden, :with_confirmed_hide) }
|
||||||
|
|
||||||
visit admin_proposal_notifications_path(filter: "with_confirmed_hide", page: 2)
|
visit admin_proposal_notifications_path(filter: "with_confirmed_hide", page: 2)
|
||||||
|
|
||||||
|
|||||||
@@ -37,8 +37,9 @@ describe "Documents" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Index (pagination)" do
|
scenario "Index (pagination)" do
|
||||||
per_page = Kaminari.config.default_per_page
|
per_page = 3
|
||||||
(per_page + 5).times { create(:document, :admin) }
|
allow(Document).to receive(:default_per_page).and_return(per_page)
|
||||||
|
(per_page + 2).times { create(:document, :admin) }
|
||||||
|
|
||||||
visit admin_site_customization_documents_path
|
visit admin_site_customization_documents_path
|
||||||
|
|
||||||
@@ -51,7 +52,7 @@ describe "Documents" do
|
|||||||
click_link "Next", exact: false
|
click_link "Next", exact: false
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(page).to have_selector("#documents .document", count: 5)
|
expect(page).to have_selector("#documents .document", count: 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Create" do
|
scenario "Create" do
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ describe "Debates" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Paginated Index" do
|
scenario "Paginated Index" do
|
||||||
per_page = Kaminari.config.default_per_page
|
per_page = 3
|
||||||
|
allow(Debate).to receive(:default_per_page).and_return(per_page)
|
||||||
(per_page + 2).times { create(:debate) }
|
(per_page + 2).times { create(:debate) }
|
||||||
|
|
||||||
visit debates_path
|
visit debates_path
|
||||||
|
|||||||
@@ -119,7 +119,8 @@ describe "Moderate budget investments" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "remembering page, filter and order" do
|
scenario "remembering page, filter and order" do
|
||||||
create_list(:budget_investment, 52, heading: heading, author: create(:user))
|
stub_const("#{ModerateActions}::PER_PAGE", 2)
|
||||||
|
create_list(:budget_investment, 4, heading: heading, author: create(:user))
|
||||||
|
|
||||||
visit moderation_budget_investments_path(filter: "all", page: "2", order: "created_at")
|
visit moderation_budget_investments_path(filter: "all", page: "2", order: "created_at")
|
||||||
|
|
||||||
|
|||||||
@@ -125,7 +125,8 @@ describe "Moderate comments" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "remembering page, filter and order" do
|
scenario "remembering page, filter and order" do
|
||||||
create_list(:comment, 52)
|
stub_const("#{ModerateActions}::PER_PAGE", 2)
|
||||||
|
create_list(:comment, 4)
|
||||||
|
|
||||||
visit moderation_comments_path(filter: "all", page: "2", order: "newest")
|
visit moderation_comments_path(filter: "all", page: "2", order: "newest")
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,8 @@ describe "Moderate debates" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "remembering page, filter and order" do
|
scenario "remembering page, filter and order" do
|
||||||
create_list(:debate, 52)
|
stub_const("#{ModerateActions}::PER_PAGE", 2)
|
||||||
|
create_list(:debate, 4)
|
||||||
|
|
||||||
visit moderation_debates_path(filter: "all", page: "2", order: "created_at")
|
visit moderation_debates_path(filter: "all", page: "2", order: "created_at")
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,8 @@ describe "Moderate proposal notifications" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "remembering page, filter and order" do
|
scenario "remembering page, filter and order" do
|
||||||
create_list(:proposal, 52)
|
stub_const("#{ModerateActions}::PER_PAGE", 2)
|
||||||
|
create_list(:proposal, 4)
|
||||||
|
|
||||||
visit moderation_proposal_notifications_path(filter: "all", page: "2", order: "created_at")
|
visit moderation_proposal_notifications_path(filter: "all", page: "2", order: "created_at")
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,8 @@ describe "Moderate proposals" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "remembering page, filter and order" do
|
scenario "remembering page, filter and order" do
|
||||||
create_list(:proposal, 52)
|
stub_const("#{ModerateActions}::PER_PAGE", 2)
|
||||||
|
create_list(:proposal, 4)
|
||||||
|
|
||||||
visit moderation_proposals_path(filter: "all", page: "2", order: "created_at")
|
visit moderation_proposals_path(filter: "all", page: "2", order: "created_at")
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,8 @@ describe "Proposals" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Pagination" do
|
scenario "Pagination" do
|
||||||
per_page = Kaminari.config.default_per_page
|
per_page = 3
|
||||||
|
allow(Proposal).to receive(:default_per_page).and_return(per_page)
|
||||||
(per_page + 2).times { create(:proposal) }
|
(per_page + 2).times { create(:proposal) }
|
||||||
|
|
||||||
visit proposals_path
|
visit proposals_path
|
||||||
|
|||||||
@@ -85,7 +85,8 @@ describe "Valuation budget investments" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Index displays investments paginated" do
|
scenario "Index displays investments paginated" do
|
||||||
per_page = Kaminari.config.default_per_page
|
per_page = 3
|
||||||
|
allow(Budget::Investment).to receive(:default_per_page).and_return(per_page)
|
||||||
(per_page + 2).times do
|
(per_page + 2).times do
|
||||||
create(:budget_investment, :visible_to_valuators, budget: budget, valuators: [valuator])
|
create(:budget_investment, :visible_to_valuators, budget: budget, valuators: [valuator])
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user