mm-friendable 1.0.0 → 1.0.1
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.
- data/VERSION +1 -1
- data/mm-friendable.gemspec +1 -1
- data/spec/mm-friendable_spec.rb +72 -0
- data/spec/support/models.rb +11 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/mm-friendable.gemspec
CHANGED
data/spec/mm-friendable_spec.rb
CHANGED
@@ -31,6 +31,12 @@ describe "MongoMapper::Plugins::Friendable" do
|
|
31
31
|
|
32
32
|
describe "add_friend!" do
|
33
33
|
|
34
|
+
it "should error if on_add_friend callback is not implemented" do
|
35
|
+
@friendable = UserNoCallbacks.create
|
36
|
+
|
37
|
+
lambda { @friendable.add_friend!(@friend) }.should raise_error(NotImplementedError)
|
38
|
+
end
|
39
|
+
|
34
40
|
it "should increment the following_count attribute" do
|
35
41
|
lambda {
|
36
42
|
@friendable.add_friend!(@friend)
|
@@ -61,4 +67,70 @@ describe "MongoMapper::Plugins::Friendable" do
|
|
61
67
|
|
62
68
|
end
|
63
69
|
|
70
|
+
describe "remove_friend!" do
|
71
|
+
|
72
|
+
before(:each) do
|
73
|
+
@friendable.add_friend!(@friend)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should error if on_add_friend callback is not implemented" do
|
77
|
+
@friendable = UserNoCallbacks.create
|
78
|
+
@friendable.class_eval {
|
79
|
+
def on_add_friend(friend)
|
80
|
+
reload
|
81
|
+
friend.reload
|
82
|
+
end
|
83
|
+
}
|
84
|
+
@friendable.add_friend!(@friend)
|
85
|
+
|
86
|
+
lambda { @friendable.remove_friend!(@friend) }.should raise_error(NotImplementedError)
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
it "should decrement the following_count attribute" do
|
91
|
+
lambda {
|
92
|
+
@friendable.remove_friend!(@friend)
|
93
|
+
|
94
|
+
}.should change(@friendable, :following_count).by(-1)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should decrement the followers_count attribute" do
|
98
|
+
lambda {
|
99
|
+
@friendable.remove_friend!(@friend)
|
100
|
+
|
101
|
+
}.should change(@friend, :followers_count).by(-1)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should remove the friend" do
|
105
|
+
@friendable.remove_friend!(@friend)
|
106
|
+
|
107
|
+
@friendable.friend_list.following_ids.should_not include(@friend.id)
|
108
|
+
@friendable.following.should_not include(@friend)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should remove the follower" do
|
112
|
+
@friendable.remove_friend!(@friend)
|
113
|
+
|
114
|
+
@friend.friend_list.followers_ids.should_not include(@friendable.id)
|
115
|
+
@friend.followers.should_not include(@friendable)
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "following?" do
|
121
|
+
|
122
|
+
before(:each) do
|
123
|
+
@friendable.add_friend!(@friend)
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should return true if following" do
|
127
|
+
@friendable.following?(@friend).should be_true
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should return false if not following" do
|
131
|
+
@friend.following?(@friendable).should be_false
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
64
136
|
end
|
data/spec/support/models.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mm-friendable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Luke Cunningham
|