Only pop bubbles in a considering state

This commit is contained in:
Jorge Manrubia
2025-04-04 12:04:13 +02:00
parent a4a2ea47ba
commit 1f4be8ed67
3 changed files with 7 additions and 5 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ module Bubble::Poppable
scope :popped, -> { joins(:pop) }
scope :active, -> { where.missing(:pop) }
scope :due_to_be_popped, -> { active.where(last_active_at: ..AUTO_POP_AFTER.ago) }
scope :due_to_be_popped, -> { considering.where(last_active_at: ..AUTO_POP_AFTER.ago) }
end
class_methods do
+2 -3
View File
@@ -48,11 +48,10 @@ class Bubble::EngageableTest < ActiveSupport::TestCase
end
test "auto_reconsider_all_stagnated" do
bubbles(:logo).update!(last_active_at: 1.day.ago - Bubble::Engageable::STAGNATED_AFTER)
bubbles(:logo).engage
bubbles(:logo, :shipping).each(&:engage)
bubbles(:logo).update!(last_active_at: 1.day.ago - Bubble::Engageable::STAGNATED_AFTER)
bubbles(:shipping).update!(last_active_at: 1.day.from_now - Bubble::Engageable::STAGNATED_AFTER)
bubbles(:shipping).engage
assert_difference -> { Bubble.considering.count }, +1 do
Bubble.auto_reconsider_all_stagnated
+4 -1
View File
@@ -16,6 +16,8 @@ class Bubble::PoppableTest < ActiveSupport::TestCase
end
test "auto_pop_all_due" do
bubbles(:logo, :shipping).each(&:reconsider)
bubbles(:logo).update!(last_active_at: 1.day.ago - Bubble::Poppable::AUTO_POP_AFTER)
bubbles(:shipping).update!(last_active_at: 1.day.from_now - Bubble::Poppable::AUTO_POP_AFTER)
@@ -23,6 +25,7 @@ class Bubble::PoppableTest < ActiveSupport::TestCase
Bubble.auto_pop_all_due
end
assert bubbles(:logo).popped?
assert bubbles(:logo).reload.popped?
assert_not bubbles(:shipping).reload.popped?
end
end