Skip to content

Commit 1ed11a4

Browse files
dornerclaude
andcommitted
Fixing flaky tests
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent dcc8e7d commit 1ed11a4

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

app/models/event.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
class Event < ApplicationRecord
1818
include Filterable
1919

20-
scope :for_organization, ->(organization_id) { where(organization_id: organization_id).order(:event_time, :updated_at) }
20+
scope :for_organization, ->(organization_id) { where(organization_id: organization_id).order(:event_time, :id) }
2121
scope :without_snapshots, -> { where("type != 'SnapshotEvent'") }
2222
scope :during, ->(range) { where(events: {created_at: range}) }
2323
scope :by_type, ->(type) { where(type: type) }

spec/services/exports/export_partners_csv_service_spec.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,15 @@
303303
end
304304

305305
it "should handle a partner with missing profile info" do
306-
# The partner_profile factory defaults to populating the no_social_media_presence, primary_contact_name, and primary_contact_email fields
306+
# The partner_profile factory defaults to populating the no_social_media_presence, primary_contact_name, and primary_contact_email fields.
307+
# Destroy the existing profile first; otherwise the factory's `partner { Partner.first || create(:partner) }`
308+
# default attaches the new profile to the same partner, briefly leaving two partner_profiles rows with the
309+
# same partner_id and making the has_one lookup nondeterministic on CI.
310+
partners.first.profile.destroy!
311+
partners.first.reload
307312
partners.first.update(profile: create(
308313
:partner_profile,
314+
partner: partners.first,
309315
no_social_media_presence: nil,
310316
primary_contact_name: nil,
311317
primary_contact_email: nil

spec/support/date_range_picker_shared_example.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def date_range_picker_select_range(range_name)
5151
visit subject
5252
date_range = "#{Time.zone.local(1919, 7, 1).to_fs(:date_picker)} - #{Time.zone.local(2020, 7, 31).to_fs(:date_picker)}"
5353
fill_in "filters_date_range", with: date_range
54-
find(:id, 'filters_date_range').native.send_keys(:enter)
54+
click_on "Filter"
5555
expect(page).to have_css("table tbody tr", count: 6)
5656
end
5757
end
@@ -69,7 +69,7 @@ def date_range_picker_select_range(range_name)
6969
visit subject
7070
date_range = "#{Time.zone.local(2019, 7, 1).to_fs(:date_picker)} - #{Time.zone.local(2019, 7, 31).to_fs(:date_picker)}"
7171
fill_in "filters_date_range", with: date_range
72-
find(:id, 'filters_date_range').native.send_keys(:enter)
72+
click_on "Filter"
7373
expect(page).to have_css("table tbody tr", count: 2)
7474
end
7575
end
@@ -79,7 +79,7 @@ def date_range_picker_select_range(range_name)
7979
visit subject
8080
date_range = "#{Time.zone.local(2019, 7, 22).to_fs(:date_picker)} - #{Time.zone.local(2019, 7, 28).to_fs(:date_picker)}"
8181
fill_in "filters_date_range", with: date_range
82-
find(:id, 'filters_date_range').native.send_keys(:enter)
82+
click_on "Filter"
8383
expect(page).to have_css("table tbody tr", count: 1)
8484
end
8585
end

0 commit comments

Comments
 (0)