notifi 0.0.3 → 0.0.4

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: cad2891de7b3d0be5b2de35d439e43063b6f9fdf
4
- data.tar.gz: d62130642a7e75f6737a8416c4e9091d3346673b
3
+ metadata.gz: ce52f781ba0c9caa7fd5278684667cf05534c862
4
+ data.tar.gz: c0b4d169eb719cccda7b6f2b37aa2783dedf9f36
5
5
  SHA512:
6
- metadata.gz: 78ffb1d52cc79ca4b0c878d201a3c9f9644ea6b8f4e568e3d25612e984927d1e9d0bcf5e2eb3aa9f764ac9901f0e6fdee3fe2c7d96746d0011c1205e2dbb9730
7
- data.tar.gz: eaceb32d9e479ec444b9a0041d1c7162d2a20d7a0767c387cb038107f2d48b44846d9247615f9ebba2059cf6c633fcb3ca3193cdbca3eb47dbcdd55feb9fcc3b
6
+ metadata.gz: 760d4930a5bc4ff683ef2c33eb958cdc2f0502ce761a8d0ba70825a30931685a1023ae38295317ee43e521df0d298af7ad7deb407f03d92b523d5c7018338d65
7
+ data.tar.gz: bb528f7438edb9f41850f4bab51209e2c70082d43e754b74da1f5f684c919928971b226dafa40edbdc2970c03fc52a3d8517cadc55efc7f7e198a3faa958f73b
@@ -15,7 +15,12 @@ module Notifi
15
15
  def subscribe_to(subscribable)
16
16
  reject_non_subscribable! subscribable
17
17
 
18
- self.subscriptions.find_or_create_by(subscriber: self, subscribable: subscribable)
18
+ sub = self.subscriptions.find_or_initialize_by(subscriber: self, subscribable: subscribable)
19
+
20
+ if sub.new_record?
21
+ sub.save
22
+ sub
23
+ end
19
24
  end
20
25
 
21
26
  def unsubscribe_from(subscribable)
@@ -1,3 +1,3 @@
1
1
  module Notifi
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -31,11 +31,18 @@ describe 'subscriber' do
31
31
  subscriber.subscriptions.count.should eq 1
32
32
  end
33
33
 
34
- it 'should return a Subscription' do
34
+ it 'should return a Subscription if subscription create' do
35
35
  subscription = subscriber.subscribe_to subscribable
36
36
 
37
37
  subscription.should be_an_instance_of Notifi::Subscription
38
38
  end
39
+
40
+ it 'should not return a Subscription if subscription already exists' do
41
+ subscriber.subscribe_to subscribable
42
+ subscription = subscriber.subscribe_to subscribable
43
+
44
+ subscription.should be nil
45
+ end
39
46
  end
40
47
 
41
48
 
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.3
4
+ version: 0.0.4
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-12-03 00:00:00.000000000 Z
11
+ date: 2013-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid