communique 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/.gitignore +1 -0
- data/README.md +1 -0
- data/assets/logo.png +0 -0
- data/lib/communique/models/notification.rb +10 -0
- data/lib/communique/version.rb +1 -1
- data/lib/communique.rb +7 -0
- data/spec/models/notification_spec.rb +53 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e1a1839bb2dd00049f9602e26f5fe86a805ac7b
|
4
|
+
data.tar.gz: c2aaaf42e4849fc803cdf3011707f99ef92f391c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05088d1b1f8d3e2bdfc5df9a9fcaf676a60459e48dbf510afdda5ce3c525c50eb916ce095f6cf9b6a854701ec0ecb32586d0f697de6aa87c5d1f4da0a1d398f2
|
7
|
+
data.tar.gz: 2d016b7f8c3acf78905a8f4481eb242b5b0484e03bae35fdee154cc6f0473b164ee477ee7af454f8592d06f53b002bfb9dcfa4882daabda0f0b2e8e2d230a48f
|
data/README.md
CHANGED
data/assets/logo.png
ADDED
Binary file
|
@@ -18,5 +18,15 @@ module Communique
|
|
18
18
|
def self.viewed_all! notifiable
|
19
19
|
notifiable.notifications.update_all(seen: true)
|
20
20
|
end
|
21
|
+
|
22
|
+
def self.viewed! notifiable, seen_notification_ids
|
23
|
+
notifiable.notifications.where(
|
24
|
+
:_id.in => seen_notification_ids
|
25
|
+
).update_all(:seen => true)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.count_unseen notifiable
|
29
|
+
notifiable.notifications.where(:seen => false).count
|
30
|
+
end
|
21
31
|
end
|
22
32
|
end
|
data/lib/communique/version.rb
CHANGED
data/lib/communique.rb
CHANGED
@@ -29,4 +29,11 @@ module Communique
|
|
29
29
|
Notification.viewed_all! notifiable
|
30
30
|
end
|
31
31
|
|
32
|
+
def self.viewed! notifiable, seen_notification_ids
|
33
|
+
Notification.viewed! notifiable, seen_notification_ids
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.count_unseen notifiable
|
37
|
+
Notification.count_unseen notifiable
|
38
|
+
end
|
32
39
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
describe Communique::Notification do
|
3
|
-
describe '#viewed_all' do
|
3
|
+
describe '#viewed_all!' do
|
4
4
|
it 'makes all notifications seen' do
|
5
5
|
dummy = NotifiableDummy.create
|
6
6
|
Communique.notify(
|
@@ -28,4 +28,56 @@ describe Communique::Notification do
|
|
28
28
|
|
29
29
|
end
|
30
30
|
end
|
31
|
+
|
32
|
+
describe '#viewed!' do
|
33
|
+
it 'makes all notifications seen' do
|
34
|
+
dummy = NotifiableDummy.create
|
35
|
+
notification_id = Communique.notify(
|
36
|
+
dummy,
|
37
|
+
'r2d2_broke_with_a_500',
|
38
|
+
name: 'broken robot',
|
39
|
+
location: 'proxy issue'
|
40
|
+
)
|
41
|
+
Communique.notify(
|
42
|
+
dummy,
|
43
|
+
'3CPO_fell_down_and_hit_his_head',
|
44
|
+
name: 'broken robot',
|
45
|
+
location: 'nginx caching issue'
|
46
|
+
)
|
47
|
+
expect(dummy.notifications.count).to be 2
|
48
|
+
|
49
|
+
expect(dummy.notifications.first.seen).to be false
|
50
|
+
expect(dummy.notifications.last.seen).to be false
|
51
|
+
|
52
|
+
Communique.viewed! dummy, [notification_id]
|
53
|
+
dummy.reload
|
54
|
+
|
55
|
+
expect(dummy.notifications.first.seen).to be true
|
56
|
+
expect(dummy.notifications.last.seen).to be false
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#count_unseen' do
|
62
|
+
it 'makes all notifications seen' do
|
63
|
+
dummy = NotifiableDummy.create
|
64
|
+
Communique.notify(
|
65
|
+
dummy,
|
66
|
+
'r2d2_broke_with_a_500',
|
67
|
+
name: 'broken robot',
|
68
|
+
location: 'proxy issue'
|
69
|
+
)
|
70
|
+
Communique.notify(
|
71
|
+
dummy,
|
72
|
+
'3CPO_fell_down_and_hit_his_head',
|
73
|
+
name: 'broken robot',
|
74
|
+
location: 'nginx caching issue'
|
75
|
+
)
|
76
|
+
expect(Communique.count_unseen(dummy)).to be 2
|
77
|
+
Communique.viewed_all! dummy
|
78
|
+
dummy.reload
|
79
|
+
expect(Communique.count_unseen(dummy)).to be 0
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
31
83
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: communique
|
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
|
- Michael Polycarpou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -93,6 +93,7 @@ files:
|
|
93
93
|
- LICENSE.txt
|
94
94
|
- README.md
|
95
95
|
- Rakefile
|
96
|
+
- assets/logo.png
|
96
97
|
- communique.gemspec
|
97
98
|
- config/mongoid.yml
|
98
99
|
- lib/communique.rb
|