notifi 0.0.2 → 0.0.3

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: 6e4a2d1542811e1450438e3baa0c53957d661b62
4
- data.tar.gz: a2631e6d89dbae06477ab1faca312fe456aa011a
3
+ metadata.gz: cad2891de7b3d0be5b2de35d439e43063b6f9fdf
4
+ data.tar.gz: d62130642a7e75f6737a8416c4e9091d3346673b
5
5
  SHA512:
6
- metadata.gz: cad3a752693240a9e9278200efc7c8bab0706a3c621add50560aed32870cf3982e6cfb737ed394c13a0c9c7dc32294d53e31c6ceff1306595fc3647a763ff699
7
- data.tar.gz: 6218e9a86974f9d5ad83927c9b05e95a1a6eaeb3838efd007f283efa0ef60f3446043ce4ec43c0ae08fcde983a923b25e954022dbbb457a5f118e70745a0f43d
6
+ metadata.gz: 78ffb1d52cc79ca4b0c878d201a3c9f9644ea6b8f4e568e3d25612e984927d1e9d0bcf5e2eb3aa9f764ac9901f0e6fdee3fe2c7d96746d0011c1205e2dbb9730
7
+ data.tar.gz: eaceb32d9e479ec444b9a0041d1c7162d2a20d7a0767c387cb038107f2d48b44846d9247615f9ebba2059cf6c633fcb3ca3193cdbca3eb47dbcdd55feb9fcc3b
@@ -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
- set[:subscription] = self
12
- set[:notifier] = notifier
13
- set[:subscriber] = self.subscriber
14
- set[:subscribable] = self.subscribable
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
- self.notification_class(event).create(set)
20
+ self.notification_class(event).create(set)
21
+ end
17
22
  end
18
23
 
19
24
  def subscribable_options
@@ -1,3 +1,3 @@
1
1
  module Notifi
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -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
- comment = Comment.create
20
+ notifier = User.create
21
21
 
22
- user.subscribe_to comment
22
+ user.subscribe_to subscribable
23
23
 
24
- comment.notify(notifier: user)
24
+ subscribable.notify(notifier: notifier)
25
25
 
26
- user.notifications.first.notifier.should eq user
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.2
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-19 00:00:00.000000000 Z
11
+ date: 2013-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid