notifi 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/notifi/subscriber.rb +6 -0
- data/lib/notifi/version.rb +1 -1
- data/spec/subscriber_spec.rb +17 -0
- 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: 6e4a2d1542811e1450438e3baa0c53957d661b62
|
4
|
+
data.tar.gz: a2631e6d89dbae06477ab1faca312fe456aa011a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cad3a752693240a9e9278200efc7c8bab0706a3c621add50560aed32870cf3982e6cfb737ed394c13a0c9c7dc32294d53e31c6ceff1306595fc3647a763ff699
|
7
|
+
data.tar.gz: 6218e9a86974f9d5ad83927c9b05e95a1a6eaeb3838efd007f283efa0ef60f3446043ce4ec43c0ae08fcde983a923b25e954022dbbb457a5f118e70745a0f43d
|
data/lib/notifi/subscriber.rb
CHANGED
@@ -24,6 +24,12 @@ module Notifi
|
|
24
24
|
self.subscriptions.destroy_all(subscribable: subscribable)
|
25
25
|
end
|
26
26
|
|
27
|
+
def mark_all_read_for(subscribable)
|
28
|
+
reject_non_subscribable! subscribable
|
29
|
+
|
30
|
+
self.notifications.where(subscribable: subscribable).set(:read, true)
|
31
|
+
end
|
32
|
+
|
27
33
|
module ClassMethods
|
28
34
|
def on_notification(&block)
|
29
35
|
self.notification_event = block
|
data/lib/notifi/version.rb
CHANGED
data/spec/subscriber_spec.rb
CHANGED
@@ -93,4 +93,21 @@ describe 'subscriber' do
|
|
93
93
|
subscriber.notifications.each { |n| n.read?.should be true }
|
94
94
|
end
|
95
95
|
end
|
96
|
+
|
97
|
+
context 'mark_all_read_for' do
|
98
|
+
it 'should set read to true on all of the users notifications for the given subscribable' do
|
99
|
+
subscription1 = subscriber.subscribe_to subscribable
|
100
|
+
subscription2 = subscriber.subscribe_to Post.create
|
101
|
+
|
102
|
+
subscription1.notify
|
103
|
+
subscription2.notify
|
104
|
+
|
105
|
+
subscriber.mark_all_read_for(subscribable)
|
106
|
+
|
107
|
+
subscriber.notifications.each do |n|
|
108
|
+
# :(
|
109
|
+
n.read?.should be (n.subscribable_id == subscribable._id)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
96
113
|
end
|
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.2
|
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-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|