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

Reduce number of records in pagination tests #3845

Merged
merged 1 commit into from
Nov 10, 2019
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
3 changes: 2 additions & 1 deletion app/controllers/concerns/moderate_actions.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
module ModerateActions
extend ActiveSupport::Concern
include Polymorphic
PER_PAGE = 50

def index
@resources = @resources.send(@current_filter)
.send("sort_by_#{@current_order}")
.page(params[:page])
.per(50)
.per(PER_PAGE)
set_resources_instance
end

Expand Down
2 changes: 1 addition & 1 deletion spec/features/admin/budget_investments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,7 @@
before { selected_bi.update(cached_votes_up: 50) }

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)

Expand Down
4 changes: 2 additions & 2 deletions spec/features/admin/hidden_budget_investments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
end

scenario "Action links remember the pagination setting and the filter" do
per_page = Kaminari.config.default_per_page
(per_page + 2).times { create(:budget_investment, :hidden, :with_confirmed_hide, heading: heading) }
allow(Budget::Investment).to receive(:default_per_page).and_return(2)
4.times { create(:budget_investment, :hidden, :with_confirmed_hide, heading: heading) }

visit admin_hidden_budget_investments_path(filter: "with_confirmed_hide", page: 2)

Expand Down
4 changes: 2 additions & 2 deletions spec/features/admin/hidden_comments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@
end

scenario "Action links remember the pagination setting and the filter" do
per_page = Kaminari.config.default_per_page
(per_page + 2).times { create(:comment, :hidden, :with_confirmed_hide) }
allow(Comment).to receive(:default_per_page).and_return(2)
4.times { create(:comment, :hidden, :with_confirmed_hide) }

visit admin_hidden_comments_path(filter: "with_confirmed_hide", page: 2)

Expand Down
4 changes: 2 additions & 2 deletions spec/features/admin/hidden_debates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
end

scenario "Action links remember the pagination setting and the filter" do
per_page = Kaminari.config.default_per_page
(per_page + 2).times { create(:debate, :hidden, :with_confirmed_hide) }
allow(Debate).to receive(:default_per_page).and_return(2)
4.times { create(:debate, :hidden, :with_confirmed_hide) }

visit admin_hidden_debates_path(filter: "with_confirmed_hide", page: 2)

Expand Down
4 changes: 2 additions & 2 deletions spec/features/admin/hidden_proposals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
end

scenario "Action links remember the pagination setting and the filter" do
per_page = Kaminari.config.default_per_page
(per_page + 2).times { create(:proposal, :hidden, :with_confirmed_hide) }
allow(Proposal).to receive(:default_per_page).and_return(2)
4.times { create(:proposal, :hidden, :with_confirmed_hide) }

visit admin_hidden_proposals_path(filter: "with_confirmed_hide", page: 2)

Expand Down
4 changes: 2 additions & 2 deletions spec/features/admin/hidden_users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
end

scenario "Action links remember the pagination setting and the filter" do
per_page = Kaminari.config.default_per_page
(per_page + 2).times { create(:user, :hidden, :with_confirmed_hide) }
allow(User).to receive(:default_per_page).and_return(2)
4.times { create(:user, :hidden, :with_confirmed_hide) }

visit admin_hidden_users_path(filter: "with_confirmed_hide", page: 2)

Expand Down
3 changes: 2 additions & 1 deletion spec/features/admin/local_census_records_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
end

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

within ".pagination" do
Expand Down
6 changes: 3 additions & 3 deletions spec/features/admin/organizations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@
expect(page).not_to have_content("Verified Organization")
end

scenario "Verifying organization links remember the pagination setting and the filter" do
per_page = Kaminari.config.default_per_page
(per_page + 2).times { create(:organization) }
scenario "Verifying organization links remembers parameters " do
allow(Organization).to receive(:default_per_page).and_return(2)
4.times { create(:organization) }

visit admin_organizations_path(filter: "pending", page: 2)

Expand Down
4 changes: 2 additions & 2 deletions spec/features/admin/proposal_notifications_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@
end

scenario "Action links remember the pagination setting and the filter" do
per_page = Kaminari.config.default_per_page
(per_page + 2).times { create(:proposal_notification, :hidden, :with_confirmed_hide) }
allow(ProposalNotification).to receive(:default_per_page).and_return(2)
4.times { create(:proposal_notification, :hidden, :with_confirmed_hide) }

visit admin_proposal_notifications_path(filter: "with_confirmed_hide", page: 2)

Expand Down
7 changes: 4 additions & 3 deletions spec/features/admin/site_customization/documents_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
end

scenario "Index (pagination)" do
per_page = Kaminari.config.default_per_page
(per_page + 5).times { create(:document, :admin) }
per_page = 3
allow(Document).to receive(:default_per_page).and_return(per_page)
(per_page + 2).times { create(:document, :admin) }

visit admin_site_customization_documents_path

Expand All @@ -51,7 +52,7 @@
click_link "Next", exact: false
end

expect(page).to have_selector("#documents .document", count: 5)
expect(page).to have_selector("#documents .document", count: 2)
end

scenario "Create" do
Expand Down
3 changes: 2 additions & 1 deletion spec/features/debates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
end

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) }

visit debates_path
Expand Down
3 changes: 2 additions & 1 deletion spec/features/moderation/budget_investments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@
end

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")

Expand Down
3 changes: 2 additions & 1 deletion spec/features/moderation/comments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@
end

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")

Expand Down
3 changes: 2 additions & 1 deletion spec/features/moderation/debates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
end

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")

Expand Down
3 changes: 2 additions & 1 deletion spec/features/moderation/proposal_notifications_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@
end

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")

Expand Down
3 changes: 2 additions & 1 deletion spec/features/moderation/proposals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
end

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")

Expand Down
3 changes: 2 additions & 1 deletion spec/features/proposals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
end

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) }

visit proposals_path
Expand Down
3 changes: 2 additions & 1 deletion spec/features/valuation/budget_investments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@
end

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
create(:budget_investment, :visible_to_valuators, budget: budget, valuators: [valuator])
end
Expand Down