Notify on pop as well

And DRY up some duplication.
This commit is contained in:
Kevin McConnell
2025-01-10 14:41:36 +00:00
parent e67ac372d3
commit 66d0f29d45
9 changed files with 37 additions and 11 deletions
+4 -1
View File
@@ -13,7 +13,10 @@ module Bubble::Poppable
end
def pop!(user: Current.user)
create_pop!(user: user) unless popped?
unless popped?
create_pop!(user: user)
track_event :popped
end
end
def unpop
+1 -1
View File
@@ -23,7 +23,7 @@ class Notifier
end
def recipients
raise NotImplementedError
bubble.bucket.users.without(creator)
end
def bubble
-4
View File
@@ -4,10 +4,6 @@ class Notifier::Commented < Notifier
"commented on: #{bubble.title}"
end
def recipients
bubble.bucket.users.without(creator)
end
def resource
event.comment
end
-4
View File
@@ -3,8 +3,4 @@ class Notifier::Created < Notifier
def body
"created: #{bubble.title}"
end
def recipients
bubble.bucket.users.without(creator)
end
end
+6
View File
@@ -0,0 +1,6 @@
class Notifier::Popped < Notifier
private
def body
"popped: #{bubble.title}"
end
end
+6
View File
@@ -72,3 +72,9 @@ shipping_created:
action: created
summary: shipping_initial_activity
created_at: <%= 1.week.ago %>
shipping_popped:
creator: kevin
action: popped
summary: shipping_initial_activity
created_at: <%= 2.days.ago %>
+3 -1
View File
@@ -9,7 +9,9 @@ class Bubble::PoppableTest < ActiveSupport::TestCase
test "popping" do
assert_not bubbles(:logo).popped?
bubbles(:logo).pop!
with_current_user(:kevin) do
bubbles(:logo).pop!
end
assert bubbles(:logo).popped?
end
+9
View File
@@ -0,0 +1,9 @@
require "test_helper"
class Notifier::PoppedTest < ActiveSupport::TestCase
test "generate populates the notification details" do
Notifier.for(events(:shipping_popped)).generate
assert_equal "popped: We need to ship the app", Notification.last.body
end
end
+8
View File
@@ -13,4 +13,12 @@ module SessionTestHelper
delete session_url
assert_not cookies[:session_token].present?
end
def with_current_user(user)
user = users(user) unless user.is_a? User
Current.session = Session.new(user: user)
yield
ensure
Current.reset_all
end
end