From cdef030f15940ef406b99d1cd95e0f738211c2bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Tue, 10 Aug 2021 22:07:46 +0200 Subject: [PATCH] Add a consistent order in system email previews Since PostgreSQL doesn't guarantee the order of the records unless an `ORDER BY` clause is used, the records sometimes had a different order. This might cause records being present in more than one page. One test was failing sometimes (when the record created first was rendered after the record created last) because there seems to be a bug in chrome/chromedriver 83 and later which causes links not to be clicked when they're right at the edge of the screen (which was the case for the notification appearing in the last place): ``` 1) System Emails Preview Pending #moderate_pending Failure/Error: click_on "Moderate notification send" Selenium::WebDriver::Error::ElementNotInteractableError: element not interactable: element has zero size (Session info: headless chrome=91.0.4472.114) ``` --- app/controllers/admin/system_emails_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/admin/system_emails_controller.rb b/app/controllers/admin/system_emails_controller.rb index d3b60c686..b71e1d32b 100644 --- a/app/controllers/admin/system_emails_controller.rb +++ b/app/controllers/admin/system_emails_controller.rb @@ -43,6 +43,7 @@ class Admin::SystemEmailsController < Admin::BaseController case @system_email when "proposal_notification_digest" @previews = ProposalNotification.where(id: unsent_proposal_notifications_ids) + .order(:id) .page(params[:page]) end end