Notify on pop as well
And DRY up some duplication.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -23,7 +23,7 @@ class Notifier
|
||||
end
|
||||
|
||||
def recipients
|
||||
raise NotImplementedError
|
||||
bubble.bucket.users.without(creator)
|
||||
end
|
||||
|
||||
def bubble
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3,8 +3,4 @@ class Notifier::Created < Notifier
|
||||
def body
|
||||
"created: #{bubble.title}"
|
||||
end
|
||||
|
||||
def recipients
|
||||
bubble.bucket.users.without(creator)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class Notifier::Popped < Notifier
|
||||
private
|
||||
def body
|
||||
"popped: #{bubble.title}"
|
||||
end
|
||||
end
|
||||
Vendored
+6
@@ -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 %>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user