Skip to content

Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.

Make two guard specs deterministic that turned CI red by chance

Guido Boyke9c3355383699
diff --git a/spec/requests/response_absence_spec.rb b/spec/requests/response_absence_spec.rb
index c7b1a11..390ffa3 100644
--- a/spec/requests/response_absence_spec.rb
+++ b/spec/requests/response_absence_spec.rb
@@ -19,8 +19,17 @@ RSpec.describe 'ResponseAbsence helper', type: :request do
expect(fails?(body, '4711')).to be(false)
end
+ # A group of four between hyphens is still part of the UUID. The third group of a random
+ # UUID starts with its version digit 4, so a four-digit number from 4000 up turns up there
+ # about once in 4096 ids (CI of #11, a saved view with the id cc2db5e9-c131-4713-...).
+ it 'takes a whole group of a UUID for no number' do
+ body = 'href="/org/x/smart_folders/cc2db5e9-c131-4711-994e-88c1f3e7a35d/edit"'
+ expect(fails?(body, 4711)).to be(false)
+ expect(fails?(body, '4711')).to be(false)
+ end
+
it 'finds the number where a reader would see it' do
- ['#4711', 'Ticket 4711', '>4711<', '4711'].each do |body|
+ ['#4711', 'Ticket 4711', '>4711<', '4711', 'ABC-4711', '-4711-'].each do |body|
expect(fails?(body, 4711)).to be(true), body
expect(fails?(body, '4711')).to be(true), body
end
diff --git a/spec/services/meetings/list_query_spec.rb b/spec/services/meetings/list_query_spec.rb
index 2f180ce..a84418a 100644
--- a/spec/services/meetings/list_query_spec.rb
+++ b/spec/services/meetings/list_query_spec.rb
@@ -102,12 +102,19 @@ RSpec.describe Meetings::ListQuery do
expect(query(smart_folder: folder)).to be_empty
end
+ # A tie on occurred_at goes by the time a meeting was entered, then by its id. The created_at
+ # values are set, not left to the clock: with three random ids and three creation times the
+ # old expectation (ids only) held in one run of six.
it 'never expands its caller scope and orders ties deterministically' do
- records = 3.times.map { meeting('Same', occurred_at: Time.zone.local(2026, 9, 16)) }
+ occurred_at = Time.zone.local(2026, 9, 16)
+ entered = Time.zone.local(2026, 9, 16, 10)
+ records = 3.times.map { meeting('Same', occurred_at: occurred_at, created_at: entered) }
+ later = meeting('Same', occurred_at: occurred_at, created_at: entered + 1.minute)
foreign_project = create(:project, organisation: organisation)
create(:meeting, organisation: organisation, project: foreign_project, creator: user, title: 'Same')
- expect(query.pluck(:id)).to eq(records.map(&:id).sort.reverse)
- expect(query(sort: { 'column' => 'title; DROP TABLE meetings', 'direction' => 'invalid' }).pluck(:id)).to eq(records.map(&:id).sort.reverse)
+ expected = [later.id] + records.map(&:id).sort.reverse
+ expect(query.pluck(:id)).to eq(expected)
+ expect(query(sort: { 'column' => 'title; DROP TABLE meetings', 'direction' => 'invalid' }).pluck(:id)).to eq(expected)
folder = save_view('creator' => [user.id])
expect(described_class.call(scope: project.meetings.where(id: records.first.id), smart_folder: folder).pluck(:id)).to eq([records.first.id])
end
diff --git a/spec/support/response_absence.rb b/spec/support/response_absence.rb
index e69742d..f60832a 100644
--- a/spec/support/response_absence.rb
+++ b/spec/support/response_absence.rb
@@ -6,18 +6,22 @@
# expect_absent(response.body, 'Board decision on budget', 'Vorstand', hidden.id, 4711)
#
# A text is a substring, a Regexp a match, and a number (Integer or a string of digits) a
-# number: not preceded or followed by a hex digit. A bare substring also matches inside a UUID
-# or an asset digest, which turned the relation specs red by chance (CI of #950; the visibility
-# spec of #949 had its own copy of this rule before).
+# number: not preceded or followed by a hex digit, and never inside a UUID. A bare substring
+# also matches inside a UUID or an asset digest, which turned the relation specs red by chance
+# (CI of #950; the visibility spec of #949 had its own copy of this rule before). The hex rule
+# alone still let a whole group between two hyphens through (CI of #11), so UUIDs are blanked
+# out before a number is looked for.
#
# Like every negative claim, it proves something only next to a positive one in the same
# response (status and an expected row or text).
module ResponseAbsence
+ UUID = /\h{8}-\h{4}-\h{4}-\h{4}-\h{12}/
+
def expect_absent(body, *needles)
needles.each do |needle|
case needle
when Regexp then expect(body).not_to match(needle)
- when Integer, /\A\d+\z/ then expect(body).not_to match(/(?<!\h)#{needle}(?!\h)/)
+ when Integer, /\A\d+\z/ then expect(body.gsub(UUID, ' ')).not_to match(/(?<!\h)#{needle}(?!\h)/)
else expect(body).not_to include(needle)
end
end