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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8345a4a8b58f6a503421a1e19d73bf07f4f78fc2
4
- data.tar.gz: bc4d59ffcd2f022c8da86950e93255eceac95446
3
+ metadata.gz: 6e4a2d1542811e1450438e3baa0c53957d661b62
4
+ data.tar.gz: a2631e6d89dbae06477ab1faca312fe456aa011a
5
5
  SHA512:
6
- metadata.gz: 9b88901322aca4e2540c0cbb823f62ce541f4191301b75436d73f5984442603b6f1e428a2aa1e79dcb0d51104e724e9c937a0f07dd558721d1769cfd2e0bf5a0
7
- data.tar.gz: fc026677730bb98cd890fd51dc89f207807f9840a8f31f804df0861fb99b6c4ddcfb72f6d86705f818c9ca0133f2cf01f944bfd14569cc01274e4dd09d9a08b0
6
+ metadata.gz: cad3a752693240a9e9278200efc7c8bab0706a3c621add50560aed32870cf3982e6cfb737ed394c13a0c9c7dc32294d53e31c6ceff1306595fc3647a763ff699
7
+ data.tar.gz: 6218e9a86974f9d5ad83927c9b05e95a1a6eaeb3838efd007f283efa0ef60f3446043ce4ec43c0ae08fcde983a923b25e954022dbbb457a5f118e70745a0f43d
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Notifi
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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.1
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-10-16 00:00:00.000000000 Z
11
+ date: 2013-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid