communique 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4282da96cb9a61a9691507909e8d511f2da8fa4b
4
- data.tar.gz: 09dc4429a835f01447c008e1e4e23db770cff6ea
3
+ metadata.gz: 7e1a1839bb2dd00049f9602e26f5fe86a805ac7b
4
+ data.tar.gz: c2aaaf42e4849fc803cdf3011707f99ef92f391c
5
5
  SHA512:
6
- metadata.gz: 2bf8e0dbfe3afe81ed803695cc0ffc30e492f8af1ee81e1e320556ac16d125aeef5efed70220e56559f0048e6155d1730c818ef0b372c6a55e5771c78c4fdd0c
7
- data.tar.gz: ac9c69e09463481bda95285af9252836ad71481238f977f11e8292034bc054b64383e39a263e49a2a038d7fdda04109e83ca7ec847cccc38b96201aed44ee251
6
+ metadata.gz: 05088d1b1f8d3e2bdfc5df9a9fcaf676a60459e48dbf510afdda5ce3c525c50eb916ce095f6cf9b6a854701ec0ecb32586d0f697de6aa87c5d1f4da0a1d398f2
7
+ data.tar.gz: 2d016b7f8c3acf78905a8f4481eb242b5b0484e03bae35fdee154cc6f0473b164ee477ee7af454f8592d06f53b002bfb9dcfa4882daabda0f0b2e8e2d230a48f
data/.gitignore CHANGED
@@ -11,4 +11,5 @@
11
11
  *.so
12
12
  *.o
13
13
  *.a
14
+ *.gem
14
15
  mkmf.log
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Communiqué
2
2
 
3
+ ![communique logo](https://raw.github.com/Vestorly/communique/master/assets/logo.png)
3
4
  Simple way to store warnings and errors affecting users as messages. Stored
4
5
  messages can be linked to a helpful link so they can read more about the problem
5
6
 
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
@@ -1,3 +1,3 @@
1
1
  module Communique
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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-25 00:00:00.000000000 Z
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