lazy_comments 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lazy_comments.gemspec +1 -1
- data/lib/commentable.rb +2 -6
- data/spec/lazy_comments_spec.rb +0 -17
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 365f9d03c229568fab1f860572a87a2742281276
|
4
|
+
data.tar.gz: b3f1cbca2110aed5755990cde92af1680adb6300
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a316251b05ebc4bbd2aff1faa7a7be724215bd3dbab0f6f7b6b4af5cb3f961c2517bd4ea09cf761a3ef135e17a2daaf211ebd78d2d5e5f60c93a1ec142f6353
|
7
|
+
data.tar.gz: dace0b22623dd011a9940a9f685590906fc9ae6888180c9f64e46f2311f647e6e1d88ee096b3af99eed5eb9f33f6c24170da7027e5a71164c308f5d96a728259
|
data/lazy_comments.gemspec
CHANGED
data/lib/commentable.rb
CHANGED
@@ -3,8 +3,8 @@ module Lazy
|
|
3
3
|
module Commentable
|
4
4
|
def self.included(comment_model)
|
5
5
|
comment_model.extend Finders
|
6
|
-
comment_model.scope :owned_by_user, ->(user) { comment_model.where(user: user) }
|
7
|
-
comment_model.scope :latest_first,
|
6
|
+
comment_model.scope :owned_by_user, -> (user) { comment_model.where(user: user) }
|
7
|
+
comment_model.scope :latest_first, -> { comment_model.reorder("created_at DESC")}
|
8
8
|
end
|
9
9
|
|
10
10
|
module Finders
|
@@ -15,10 +15,6 @@ module Lazy
|
|
15
15
|
def for_topic(topic)
|
16
16
|
where(topic: topic)
|
17
17
|
end
|
18
|
-
|
19
|
-
def in_group(group)
|
20
|
-
group.present? ? where(group: group) : self
|
21
|
-
end
|
22
18
|
end
|
23
19
|
end
|
24
20
|
end
|
data/spec/lazy_comments_spec.rb
CHANGED
@@ -62,23 +62,6 @@ describe "Lazy Comment" do
|
|
62
62
|
expect(comments.size).to eq 2
|
63
63
|
end
|
64
64
|
end
|
65
|
-
|
66
|
-
describe "#in_groups" do
|
67
|
-
before(:each) do
|
68
|
-
@dorian_gray = Post.create(title: "A picture of Dorian Gray", body: "The story goes...")
|
69
|
-
@dorian_gray.comments.create(body: "lovely story", group: "haters")
|
70
|
-
@dorian_gray.comments.create(body: "lovely story", group: :fans)
|
71
|
-
end
|
72
|
-
|
73
|
-
it "filters by group" do
|
74
|
-
haters_comments = @dorian_gray.comments.in_group(:haters)
|
75
|
-
expect(haters_comments.size).to eq 1
|
76
|
-
|
77
|
-
fan_comments = @dorian_gray.comments.in_group(:fans)
|
78
|
-
expect(fan_comments.size).to eq 1
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
65
|
end
|
83
66
|
end
|
84
67
|
end
|