notifi 0.0.6 → 0.0.7

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: 36c38c88ddf2a7b030ecc31fc37a5ff4c97369be
4
- data.tar.gz: 34312130fbf15d15d43785641ffbb8e5521b9aba
3
+ metadata.gz: 34ee8693ae3ac0024d6324c8e59236d0ba56c72f
4
+ data.tar.gz: 34a0f0b1a98bd3304abec9eabf33f76d2c7f3eb5
5
5
  SHA512:
6
- metadata.gz: 6f4778900576c6454425c9f212865833ab531672ddd32fde268abc5e3157f7d2d4cad0faf206524856815a5f2e76ecd1661d0e7b75c01a23b26ee07d39fffce8
7
- data.tar.gz: cf97dc777b4f2e506050c4305e31c7a72625752600cc011c32459308576802ba12a5c61f8a8d50354169365926809ed6c0d7f59d70ccd50c2914b0079ff4d9e1
6
+ metadata.gz: 38186459c6f94ad9ea22ad596de5af0a8a937db604ab463229a745473bfc6acbdb44b3ae5b242c5920a4c40e87afeb3e796e4e24f9e10055b5bd1729e0f53474
7
+ data.tar.gz: 05d9a6937ff2ff140a86873fcb2d40a8230d67458f784fedc08750ed55e0e388e7d9b3ec21a2007217a22be0d08569fecc52558b795c837543fc193bc72c87c4
@@ -8,7 +8,6 @@ module Notifi
8
8
  belongs_to :notifier, polymorphic: true, index: true
9
9
  belongs_to :subscribable, polymorphic: true, index: true
10
10
 
11
- field :read, type: Boolean, default: false
12
11
  field :message, type: String
13
12
 
14
13
  after_create do |n|
@@ -22,9 +21,5 @@ module Notifi
22
21
  def fire_notification_event
23
22
  self.subscriber.notification_event.call(self) if self.notification_event?
24
23
  end
25
-
26
- def mark_as_read
27
- self.update_attribute :read, true
28
- end
29
24
  end
30
25
  end
@@ -3,11 +3,7 @@ module Notifi
3
3
  def self.included(base)
4
4
  base.has_many :subscriptions, class_name: Subscription.name, dependent: :destroy, inverse_of: :subscriber
5
5
  base.has_many :triggered_notifications, class_name: Notification.name, dependent: :destroy, inverse_of: :notifier
6
- base.has_many :notifications, class_name: Notification.name, dependent: :destroy, inverse_of: :subscriber do
7
- def mark_as_read
8
- self.each(&:mark_as_read)
9
- end
10
- end
6
+ base.has_many :notifications, class_name: Notification.name, dependent: :destroy, inverse_of: :subscriber
11
7
 
12
8
  base.extend ClassMethods
13
9
  end
@@ -29,12 +25,6 @@ module Notifi
29
25
  self.subscriptions.destroy_all(subscribable: subscribable)
30
26
  end
31
27
 
32
- def mark_all_read_for(subscribable)
33
- reject_non_subscribable! subscribable
34
-
35
- self.notifications.where(subscribable: subscribable).set(:read, true)
36
- end
37
-
38
28
  module ClassMethods
39
29
  def on_notification(&block)
40
30
  self.notification_event = block
@@ -1,3 +1,3 @@
1
1
  module Notifi
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -87,34 +87,4 @@ describe 'subscriber' do
87
87
  thing.class.instance_variable_get(:@block_called).should be true
88
88
  end
89
89
  end
90
-
91
- context 'mark_as_read' do
92
- it 'should set read to true on all notifications' do
93
- subscription = subscriber.subscribe_to subscribable
94
-
95
- subscription.notify
96
- subscription.notify
97
-
98
- subscriber.notifications.mark_as_read
99
-
100
- subscriber.notifications.each { |n| n.read?.should be true }
101
- end
102
- end
103
-
104
- context 'mark_all_read_for' do
105
- it 'should set read to true on all of the users notifications for the given subscribable' do
106
- subscription1 = subscriber.subscribe_to subscribable
107
- subscription2 = subscriber.subscribe_to Post.create
108
-
109
- subscription1.notify
110
- subscription2.notify
111
-
112
- subscriber.mark_all_read_for(subscribable)
113
-
114
- subscriber.notifications.each do |n|
115
- # :(
116
- n.read?.should be (n.subscribable_id == subscribable._id)
117
- end
118
- end
119
- end
120
90
  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.6
4
+ version: 0.0.7
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-11 00:00:00.000000000 Z
11
+ date: 2014-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -101,7 +101,6 @@ files:
101
101
  - lib/notifi/version.rb
102
102
  - notifi.gemspec
103
103
  - spec/mongoid.yml
104
- - spec/notification_spec.rb
105
104
  - spec/spec_helper.rb
106
105
  - spec/subscribable_spec.rb
107
106
  - spec/subscriber_spec.rb
@@ -131,7 +130,6 @@ specification_version: 4
131
130
  summary: Simple frame for creating subsciption and notificaton records
132
131
  test_files:
133
132
  - spec/mongoid.yml
134
- - spec/notification_spec.rb
135
133
  - spec/spec_helper.rb
136
134
  - spec/subscribable_spec.rb
137
135
  - spec/subscriber_spec.rb
@@ -1,15 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'notification' do
4
- let(:notification) { Notifi::Notification.create }
5
-
6
- it 'should default to unread' do
7
- notification.read?.should be false
8
- end
9
-
10
- it 'should be able to mark_as_read' do
11
- notification.mark_as_read
12
-
13
- notification.read?.should be true
14
- end
15
- end