unread-mongoid 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/unread_mongoid/base.rb +2 -2
- data/lib/unread_mongoid/version.rb +1 -1
- data/test/unread_test.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adc69505c8208e251baa393dbf71f86609691942
|
4
|
+
data.tar.gz: 07e4fff7bf3a8ea8757a1e2ea96d37dddc540ec4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18ac058f67de7193ece5002d70a923a96ddfe45a21f33b817c5835f60fd83f34d3a56c3e3f730768e3571e0109f0edfea73e7f969489b27fb88f71b1e65b2eb2
|
7
|
+
data.tar.gz: 29c248a3de7261a8de7a5b23564206cab8cc12c4bb574ccc5a2693097668f8d3bc782319dfdcad921d8f9c691db0a2f9bdd4c6d4b0ce167f60fe2c7a5be053ac
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ Unread-Mongoid
|
|
4
4
|
Ruby gem to manage read/unread status of Mongoid objects.
|
5
5
|
|
6
6
|
## Credit
|
7
|
-
First and foremost this is a fork of [Unread](https://github.com/ledermann/unread) by [Georg Ledermann](http://www.georg-ledermann.de). If you don't have to use Mongo for this I highly
|
7
|
+
First and foremost this is a fork of [Unread](https://github.com/ledermann/unread) by [Georg Ledermann](http://www.georg-ledermann.de). If you don't have to use Mongo for this I highly reccomend you use his gem, this is a task much better suited to a relational db.
|
8
8
|
|
9
9
|
## Features
|
10
10
|
|
data/lib/unread_mongoid/base.rb
CHANGED
@@ -7,7 +7,7 @@ module UnreadMongoid
|
|
7
7
|
def acts_as_reader
|
8
8
|
ReadMark.belongs_to :user, :class_name => self.to_s
|
9
9
|
|
10
|
-
has_many :read_marks, :dependent => :
|
10
|
+
has_many :read_marks, :dependent => :destroy, :foreign_key => 'user_id', :inverse_of => :user
|
11
11
|
|
12
12
|
after_create do |user|
|
13
13
|
# We assume that a new user should not be tackled by tons of old messages
|
@@ -26,7 +26,7 @@ module UnreadMongoid
|
|
26
26
|
|
27
27
|
self.readable_options = options
|
28
28
|
|
29
|
-
has_many :read_marks, :as => :readable, :dependent => :
|
29
|
+
has_many :read_marks, :as => :readable, :dependent => :destroy
|
30
30
|
|
31
31
|
# :(
|
32
32
|
after_save do |doc|
|
data/test/unread_test.rb
CHANGED
@@ -169,6 +169,13 @@ class UnreadTest < ActiveSupport::TestCase
|
|
169
169
|
assert_equal 2, ReadMark.global.count
|
170
170
|
end
|
171
171
|
|
172
|
+
def test_destroys_readmarks_when_readable_is_destroyed
|
173
|
+
count = ReadMark.count
|
174
|
+
@email1.mark_as_read! for: @reader
|
175
|
+
assert_equal count + 1, ReadMark.count
|
176
|
+
@email1.destroy
|
177
|
+
assert_equal count, ReadMark.count
|
178
|
+
end
|
172
179
|
private
|
173
180
|
def wait
|
174
181
|
Timecop.freeze(1.minute.from_now.change(:usec => 0))
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unread-mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hunter Haydel
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|