Skip to content

Commit

Permalink
Fix postgres tests where its not setting created at correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
npezza93 committed Sep 17, 2024
1 parent f55303f commit 8bbc0fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions app/models/solid_cable/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module SolidCable
class Message < SolidCable::Record
scope :trimmable, lambda {
where(created_at: ..::SolidCable.message_retention.ago)
where(created_at: ...::SolidCable.message_retention.ago)
}
scope :broadcastable, lambda { |channels, last_id|
where(channel_hash: channel_hashes_for(channels)).
Expand All @@ -12,7 +12,8 @@ class Message < SolidCable::Record

class << self
def broadcast(channel, payload)
insert({ channel:, payload:, channel_hash: channel_hash_for(channel) })
insert({ created_at: Time.current, channel:, payload:,
channel_hash: channel_hash_for(channel) })
end

def channel_hashes_for(channels)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ActionCable::SubscriptionAdapter::SolidCableTest < ActionCable::TestCase

test "trims_after_unsubscribe" do
SolidCable.stub(:trim_chance, 99.999999) do
with_cable_config message_retention: "2.seconds", trim_batch_size: 1 do
with_cable_config message_retention: "2.seconds", trim_batch_size: 2 do
subscribe_as_queue("channel") do |queue|
4.times do
@tx_adapter.broadcast("channel", "hello world")
Expand Down

0 comments on commit 8bbc0fb

Please sign in to comment.