notifi 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/notifi/subscription.rb +10 -5
- data/lib/notifi/version.rb +1 -1
- data/spec/subscribable_spec.rb +13 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cad2891de7b3d0be5b2de35d439e43063b6f9fdf
|
4
|
+
data.tar.gz: d62130642a7e75f6737a8416c4e9091d3346673b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78ffb1d52cc79ca4b0c878d201a3c9f9644ea6b8f4e568e3d25612e984927d1e9d0bcf5e2eb3aa9f764ac9901f0e6fdee3fe2c7d96746d0011c1205e2dbb9730
|
7
|
+
data.tar.gz: eaceb32d9e479ec444b9a0041d1c7162d2a20d7a0767c387cb038107f2d48b44846d9247615f9ebba2059cf6c633fcb3ca3193cdbca3eb47dbcdd55feb9fcc3b
|
data/lib/notifi/subscription.rb
CHANGED
@@ -8,12 +8,17 @@ module Notifi
|
|
8
8
|
has_many :notifications, dependent: :destroy, inverse_of: :subscription
|
9
9
|
|
10
10
|
def notify(event=:default, notifier=nil, set: {})
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
# TODO I wanted to do this in the subscribable notify method so you could
|
12
|
+
# still forceably notifiy the notifier, but for the life of me I couldn't
|
13
|
+
# get it to work.
|
14
|
+
if notifier != self.subscriber
|
15
|
+
set[:subscription] = self
|
16
|
+
set[:notifier] = notifier
|
17
|
+
set[:subscriber] = self.subscriber
|
18
|
+
set[:subscribable] = self.subscribable
|
15
19
|
|
16
|
-
|
20
|
+
self.notification_class(event).create(set)
|
21
|
+
end
|
17
22
|
end
|
18
23
|
|
19
24
|
def subscribable_options
|
data/lib/notifi/version.rb
CHANGED
data/spec/subscribable_spec.rb
CHANGED
@@ -17,13 +17,22 @@ describe 'subscribable' do
|
|
17
17
|
|
18
18
|
it 'should be able to provide a notifier' do
|
19
19
|
user = User.create
|
20
|
-
|
20
|
+
notifier = User.create
|
21
21
|
|
22
|
-
user.subscribe_to
|
22
|
+
user.subscribe_to subscribable
|
23
23
|
|
24
|
-
|
24
|
+
subscribable.notify(notifier: notifier)
|
25
25
|
|
26
|
-
user.notifications.first.notifier.should eq
|
26
|
+
user.notifications.first.notifier.should eq notifier
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should not notify the notifier' do
|
30
|
+
notifier = User.create
|
31
|
+
notifier.subscribe_to subscribable
|
32
|
+
|
33
|
+
subscribable.notify(notifier: notifier)
|
34
|
+
|
35
|
+
notifier.notifications.empty?.should be true
|
27
36
|
end
|
28
37
|
|
29
38
|
context 'custom notifications' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notifi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hunter Haydel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|