Skip to content

Commit 30fa82c

Browse files
committed
Update assertions for Rails 7
1 parent ec703d7 commit 30fa82c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

spec/graphql/dataloader/active_record_association_source_spec.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
wilco = ::Band.find(4)
131131
chon = ::Band.find(3)
132132
albums_by_band = nil
133+
one_month_ago = nil
133134
log = with_active_record_log(colorize: false) do
134135
one_month_ago = 1.month.ago.end_of_day
135136
albums_by_band_1 = d.with(GraphQL::Dataloader::ActiveRecordAssociationSource, :albums, Album.where("created_at >= ?", one_month_ago)).request(wilco)
@@ -138,7 +139,13 @@
138139
end
139140

140141
assert_equal [[6], [4, 5]], albums_by_band.map { |al| al.map(&:id) }
141-
assert_includes log, 'SELECT "albums".* FROM "albums" WHERE (created_at >= ?) AND "albums"."band_id" IN (?, ?)'
142+
expected_log = if Rails::VERSION::STRING > "8"
143+
'SELECT "albums".* FROM "albums" WHERE (created_at >= ?) AND "albums"."band_id" IN (?, ?)'
144+
else
145+
'SELECT "albums".* FROM "albums" WHERE (created_at >= ' + one_month_ago.utc.strftime("'%Y-%m-%d %H:%M:%S.%6N'") + ') AND "albums"."band_id" IN (?, ?)'
146+
end
147+
148+
assert_includes log, expected_log
142149

143150
albums = nil
144151
log = with_active_record_log(colorize: false) do

0 commit comments

Comments
 (0)