mongoid_followable 0.0.1 → 0.1.0
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/.idea/misc.xml +1 -1
- data/.idea/mongoid_followable.iml +25 -0
- data/.idea/workspace.xml +110 -57
- data/README.rdoc +35 -27
- data/app/models/follow.rb +12 -0
- data/lib/mongoid_followable.rb +2 -151
- data/lib/mongoid_followable/followable.rb +175 -0
- data/lib/mongoid_followable/version.rb +1 -1
- data/mongoid_followable.gemspec +1 -1
- data/spec/models/group.rb +4 -0
- data/spec/mongoid/followable_spec.rb +64 -36
- data/spec/spec_helper.rb +2 -2
- metadata +5 -2
data/.idea/misc.xml
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
<component name="DependencyValidationManager">
|
|
4
4
|
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
|
|
5
5
|
</component>
|
|
6
|
-
<component name="ProjectRootManager" version="2" project-jdk-name="
|
|
6
|
+
<component name="ProjectRootManager" version="2" project-jdk-name="ruby-1.9.2-p0" project-jdk-type="RUBY_SDK" />
|
|
7
7
|
</project>
|
|
8
8
|
|
|
@@ -1,10 +1,35 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<module type="RUBY_MODULE" version="4">
|
|
3
|
+
<component name="GemRequirementsHolder" version="3">
|
|
4
|
+
<requirement>
|
|
5
|
+
<requirement>
|
|
6
|
+
<dependency name="bson_ext" version="1.3.0" bound="LATEST_IN_BRANCH" git="false" path="false" doRequire="true" />
|
|
7
|
+
</requirement>
|
|
8
|
+
<source from="Gemfile" />
|
|
9
|
+
</requirement>
|
|
10
|
+
<requirement>
|
|
11
|
+
<requirement>
|
|
12
|
+
<dependency name="mongoid" version="2.0.1" bound="LATEST_IN_BRANCH" git="false" path="false" doRequire="true" />
|
|
13
|
+
</requirement>
|
|
14
|
+
<source from="Gemfile" />
|
|
15
|
+
</requirement>
|
|
16
|
+
</component>
|
|
3
17
|
<component name="NewModuleRootManager">
|
|
4
18
|
<content url="file://$MODULE_DIR$" />
|
|
5
19
|
<orderEntry type="inheritedJdk" />
|
|
6
20
|
<orderEntry type="sourceFolder" forTests="false" />
|
|
7
21
|
<orderEntry type="library" scope="PROVIDED" name="[gem] bundler (v1.0.7, /home/tomato/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.7)" level="application" />
|
|
22
|
+
<orderEntry type="library" scope="PROVIDED" name="[gem] mongoid (v2.0.1, /home/tomato/.rvm/gems/ruby-1.9.2-p136/gems/mongoid-2.0.1)" level="application" />
|
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="[gem] bson_ext (v1.3.1, /home/tomato/.rvm/gems/ruby-1.9.2-p136/gems/bson_ext-1.3.1)" level="application" />
|
|
24
|
+
<orderEntry type="library" scope="PROVIDED" name="[gem] activesupport (v3.0.7, /home/tomato/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.7)" level="application" />
|
|
25
|
+
<orderEntry type="library" scope="PROVIDED" name="[gem] builder (v2.1.2, /home/tomato/.rvm/gems/ruby-1.9.2-p136/gems/builder-2.1.2)" level="application" />
|
|
26
|
+
<orderEntry type="library" scope="PROVIDED" name="[gem] bson (v1.3.1, /home/tomato/.rvm/gems/ruby-1.9.2-p136/gems/bson-1.3.1)" level="application" />
|
|
27
|
+
<orderEntry type="library" scope="PROVIDED" name="[gem] tzinfo (v0.3.27, /home/tomato/.rvm/gems/ruby-1.9.2-p136/gems/tzinfo-0.3.27)" level="application" />
|
|
28
|
+
<orderEntry type="library" scope="PROVIDED" name="[gem] i18n (v0.5.0, /home/tomato/.rvm/gems/ruby-1.9.2-p136/gems/i18n-0.5.0)" level="application" />
|
|
29
|
+
<orderEntry type="library" scope="PROVIDED" name="[gem] activemodel (v3.0.7, /home/tomato/.rvm/gems/ruby-1.9.2-p136/gems/activemodel-3.0.7)" level="application" />
|
|
30
|
+
<orderEntry type="library" scope="PROVIDED" name="[gem] will_paginate (v3.0.pre2, /home/tomato/.rvm/gems/ruby-1.9.2-p136/gems/will_paginate-3.0.pre2)" level="application" />
|
|
31
|
+
<orderEntry type="library" scope="PROVIDED" name="[gem] mongo (v1.3.1, /home/tomato/.rvm/gems/ruby-1.9.2-p136/gems/mongo-1.3.1)" level="application" />
|
|
32
|
+
<orderEntry type="library" scope="PROVIDED" name="[gem] bundler (v1.0.13, /home/tomato/.gem/ruby/1.9.1/gems/bundler-1.0.13)" level="application" />
|
|
8
33
|
</component>
|
|
9
34
|
</module>
|
|
10
35
|
|
data/.idea/workspace.xml
CHANGED
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
<project version="4">
|
|
3
3
|
<component name="ChangeListManager">
|
|
4
4
|
<list default="true" id="90bdec60-890b-4083-b05d-2f665a1f4d70" name="Default" comment="">
|
|
5
|
-
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR
|
|
6
|
-
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/
|
|
7
|
-
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/
|
|
8
|
-
<change type="
|
|
9
|
-
<change type="
|
|
10
|
-
<change type="
|
|
11
|
-
<change type="
|
|
12
|
-
<change type="
|
|
13
|
-
<change type="
|
|
5
|
+
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/app/models/follow.rb" />
|
|
6
|
+
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/lib/mongoid_followable/followable.rb" />
|
|
7
|
+
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/spec/models/group.rb" />
|
|
8
|
+
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/mongoid_followable.iml" afterPath="$PROJECT_DIR$/.idea/mongoid_followable.iml" />
|
|
9
|
+
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/misc.xml" afterPath="$PROJECT_DIR$/.idea/misc.xml" />
|
|
10
|
+
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
|
|
11
|
+
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/mongoid_followable.rb" afterPath="$PROJECT_DIR$/lib/mongoid_followable.rb" />
|
|
12
|
+
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/mongoid_followable/version.rb" afterPath="$PROJECT_DIR$/lib/mongoid_followable/version.rb" />
|
|
13
|
+
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/mongoid_followable.gemspec" afterPath="$PROJECT_DIR$/mongoid_followable.gemspec" />
|
|
14
|
+
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/spec/mongoid/followable_spec.rb" afterPath="$PROJECT_DIR$/spec/mongoid/followable_spec.rb" />
|
|
15
|
+
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/spec/spec_helper.rb" afterPath="$PROJECT_DIR$/spec/spec_helper.rb" />
|
|
14
16
|
</list>
|
|
15
17
|
<ignored path="mongoid_followable.iws" />
|
|
16
18
|
<ignored path=".idea/workspace.xml" />
|
|
@@ -33,26 +35,7 @@
|
|
|
33
35
|
<favorites_list name="mongoid_followable" />
|
|
34
36
|
</component>
|
|
35
37
|
<component name="FileEditorManager">
|
|
36
|
-
<leaf
|
|
37
|
-
<file leaf-file-name="followable_spec.rb" pinned="false" current="false" current-in-tab="false">
|
|
38
|
-
<entry file="file://$PROJECT_DIR$/spec/mongoid/followable_spec.rb">
|
|
39
|
-
<provider selected="true" editor-type-id="text-editor">
|
|
40
|
-
<state line="42" column="33" selection-start="1138" selection-end="1138" vertical-scroll-proportion="0.0">
|
|
41
|
-
<folding />
|
|
42
|
-
</state>
|
|
43
|
-
</provider>
|
|
44
|
-
</entry>
|
|
45
|
-
</file>
|
|
46
|
-
<file leaf-file-name="mongoid_followable.rb" pinned="false" current="true" current-in-tab="true">
|
|
47
|
-
<entry file="file://$PROJECT_DIR$/lib/mongoid_followable.rb">
|
|
48
|
-
<provider selected="true" editor-type-id="text-editor">
|
|
49
|
-
<state line="11" column="23" selection-start="297" selection-end="297" vertical-scroll-proportion="0.23878437">
|
|
50
|
-
<folding />
|
|
51
|
-
</state>
|
|
52
|
-
</provider>
|
|
53
|
-
</entry>
|
|
54
|
-
</file>
|
|
55
|
-
</leaf>
|
|
38
|
+
<leaf />
|
|
56
39
|
</component>
|
|
57
40
|
<component name="FindManager">
|
|
58
41
|
<FindUsagesManager>
|
|
@@ -66,12 +49,19 @@
|
|
|
66
49
|
<component name="IdeDocumentHistory">
|
|
67
50
|
<option name="changedFiles">
|
|
68
51
|
<list>
|
|
69
|
-
<option value="$PROJECT_DIR$/
|
|
52
|
+
<option value="$PROJECT_DIR$/spec/models/user.rb" />
|
|
53
|
+
<option value="$PROJECT_DIR$/app/models/followee.rb" />
|
|
54
|
+
<option value="$PROJECT_DIR$/app/models/follower.rb" />
|
|
55
|
+
<option value="$PROJECT_DIR$/spec/models/group.rb" />
|
|
70
56
|
<option value="$PROJECT_DIR$/lib/mongoid_followable/version.rb" />
|
|
57
|
+
<option value="$PROJECT_DIR$/lib/mongoid_followable/follow.rb" />
|
|
58
|
+
<option value="$PROJECT_DIR$/lib/generators/mongoid_followable/install_generator.rb" />
|
|
71
59
|
<option value="$PROJECT_DIR$/spec/spec_helper.rb" />
|
|
72
|
-
<option value="$PROJECT_DIR$/spec/models/user.rb" />
|
|
73
|
-
<option value="$PROJECT_DIR$/spec/mongoid/followable_spec.rb" />
|
|
74
60
|
<option value="$PROJECT_DIR$/lib/mongoid_followable.rb" />
|
|
61
|
+
<option value="$PROJECT_DIR$/app/models/follow.rb" />
|
|
62
|
+
<option value="$PROJECT_DIR$/spec/mongoid/followable_spec.rb" />
|
|
63
|
+
<option value="$PROJECT_DIR$/lib/mongoid_followable/followable.rb" />
|
|
64
|
+
<option value="$PROJECT_DIR$/mongoid_followable.gemspec" />
|
|
75
65
|
</list>
|
|
76
66
|
</option>
|
|
77
67
|
</component>
|
|
@@ -101,7 +91,6 @@
|
|
|
101
91
|
<sortByType />
|
|
102
92
|
</navigator>
|
|
103
93
|
<panes>
|
|
104
|
-
<pane id="Scope" />
|
|
105
94
|
<pane id="Favorites" />
|
|
106
95
|
<pane id="ProjectPane">
|
|
107
96
|
<subPane>
|
|
@@ -185,10 +174,53 @@
|
|
|
185
174
|
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
|
186
175
|
</PATH_ELEMENT>
|
|
187
176
|
</PATH>
|
|
177
|
+
<PATH>
|
|
178
|
+
<PATH_ELEMENT>
|
|
179
|
+
<option name="myItemId" value="mongoid_followable" />
|
|
180
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
|
181
|
+
</PATH_ELEMENT>
|
|
182
|
+
<PATH_ELEMENT>
|
|
183
|
+
<option name="myItemId" value="mongoid_followable" />
|
|
184
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
|
185
|
+
</PATH_ELEMENT>
|
|
186
|
+
<PATH_ELEMENT>
|
|
187
|
+
<option name="myItemId" value="lib" />
|
|
188
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
|
189
|
+
</PATH_ELEMENT>
|
|
190
|
+
<PATH_ELEMENT>
|
|
191
|
+
<option name="myItemId" value="mongoid_followable" />
|
|
192
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
|
193
|
+
</PATH_ELEMENT>
|
|
194
|
+
</PATH>
|
|
195
|
+
<PATH>
|
|
196
|
+
<PATH_ELEMENT>
|
|
197
|
+
<option name="myItemId" value="mongoid_followable" />
|
|
198
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
|
199
|
+
</PATH_ELEMENT>
|
|
200
|
+
<PATH_ELEMENT>
|
|
201
|
+
<option name="myItemId" value="mongoid_followable" />
|
|
202
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
|
203
|
+
</PATH_ELEMENT>
|
|
204
|
+
<PATH_ELEMENT>
|
|
205
|
+
<option name="myItemId" value="app" />
|
|
206
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
|
207
|
+
</PATH_ELEMENT>
|
|
208
|
+
<PATH_ELEMENT>
|
|
209
|
+
<option name="myItemId" value="models" />
|
|
210
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
|
211
|
+
</PATH_ELEMENT>
|
|
212
|
+
</PATH>
|
|
188
213
|
</subPane>
|
|
189
214
|
</pane>
|
|
215
|
+
<pane id="Scope" />
|
|
190
216
|
</panes>
|
|
191
217
|
</component>
|
|
218
|
+
<component name="RecentsManager">
|
|
219
|
+
<key name="CopyFile.RECENT_KEYS">
|
|
220
|
+
<recent name="$PROJECT_DIR$/spec/mongoid" />
|
|
221
|
+
<recent name="$PROJECT_DIR$/spec/models" />
|
|
222
|
+
</key>
|
|
223
|
+
</component>
|
|
192
224
|
<component name="RunManager">
|
|
193
225
|
<configuration default="true" type="RubyRunConfigurationType" factoryName="Ruby">
|
|
194
226
|
<module name="" />
|
|
@@ -228,30 +260,31 @@
|
|
|
228
260
|
</component>
|
|
229
261
|
<component name="TaskManager">
|
|
230
262
|
<task active="true" id="Default" summary="Default task">
|
|
263
|
+
<changelist id="90bdec60-890b-4083-b05d-2f665a1f4d70" name="Default" comment="" />
|
|
231
264
|
<created>1308618686031</created>
|
|
232
265
|
<updated>1308618686031</updated>
|
|
233
266
|
</task>
|
|
234
267
|
<servers />
|
|
235
268
|
</component>
|
|
236
269
|
<component name="ToolWindowManager">
|
|
237
|
-
<frame x="
|
|
238
|
-
<editor active="
|
|
270
|
+
<frame x="0" y="24" width="1280" height="752" extended-state="1" />
|
|
271
|
+
<editor active="false" />
|
|
239
272
|
<layout>
|
|
240
|
-
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="
|
|
273
|
+
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
|
241
274
|
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
|
242
|
-
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32963988" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
|
243
275
|
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="true" content_ui="tabs" />
|
|
244
|
-
<window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="
|
|
245
|
-
<window_info id="Project" active="
|
|
276
|
+
<window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
|
277
|
+
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.1770335" sideWeight="0.67128986" order="0" side_tool="false" content_ui="tabs" />
|
|
246
278
|
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
|
247
279
|
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
|
248
|
-
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="
|
|
280
|
+
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
|
249
281
|
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
|
|
250
282
|
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
|
251
283
|
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
|
284
|
+
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32871014" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
|
252
285
|
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
|
253
|
-
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
|
254
286
|
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
|
|
287
|
+
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
|
255
288
|
</layout>
|
|
256
289
|
</component>
|
|
257
290
|
<component name="VcsManagerConfiguration">
|
|
@@ -287,58 +320,78 @@
|
|
|
287
320
|
<breakpoint-manager />
|
|
288
321
|
</component>
|
|
289
322
|
<component name="editorHistoryManager">
|
|
290
|
-
<entry file="file://$PROJECT_DIR$/
|
|
323
|
+
<entry file="file://$PROJECT_DIR$/Rakefile">
|
|
291
324
|
<provider selected="true" editor-type-id="text-editor">
|
|
292
|
-
<state line="
|
|
293
|
-
<folding />
|
|
294
|
-
</state>
|
|
325
|
+
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" />
|
|
295
326
|
</provider>
|
|
296
327
|
</entry>
|
|
297
|
-
<entry file="file://$PROJECT_DIR$/
|
|
328
|
+
<entry file="file://$PROJECT_DIR$/Gemfile">
|
|
298
329
|
<provider selected="true" editor-type-id="text-editor">
|
|
299
|
-
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0"
|
|
330
|
+
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" />
|
|
331
|
+
</provider>
|
|
332
|
+
</entry>
|
|
333
|
+
<entry file="file://$PROJECT_DIR$/LICENSE.txt">
|
|
334
|
+
<provider selected="true" editor-type-id="text-editor">
|
|
335
|
+
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" />
|
|
336
|
+
</provider>
|
|
337
|
+
</entry>
|
|
338
|
+
<entry file="file://$PROJECT_DIR$/spec/models/group.rb">
|
|
339
|
+
<provider selected="true" editor-type-id="text-editor">
|
|
340
|
+
<state line="2" column="29" selection-start="69" selection-end="69" vertical-scroll-proportion="0.0">
|
|
300
341
|
<folding />
|
|
301
342
|
</state>
|
|
302
343
|
</provider>
|
|
303
344
|
</entry>
|
|
304
345
|
<entry file="file://$PROJECT_DIR$/spec/models/user.rb">
|
|
305
346
|
<provider selected="true" editor-type-id="text-editor">
|
|
306
|
-
<state line="
|
|
347
|
+
<state line="3" column="9" selection-start="72" selection-end="72" vertical-scroll-proportion="0.0">
|
|
307
348
|
<folding />
|
|
308
349
|
</state>
|
|
309
350
|
</provider>
|
|
310
351
|
</entry>
|
|
311
|
-
<entry file="file://$PROJECT_DIR$/lib/mongoid_followable
|
|
352
|
+
<entry file="file://$PROJECT_DIR$/lib/mongoid_followable.rb">
|
|
312
353
|
<provider selected="true" editor-type-id="text-editor">
|
|
313
|
-
<state line="
|
|
354
|
+
<state line="1" column="21" selection-start="96" selection-end="96" vertical-scroll-proportion="0.02529511">
|
|
314
355
|
<folding />
|
|
315
356
|
</state>
|
|
316
357
|
</provider>
|
|
317
358
|
</entry>
|
|
318
359
|
<entry file="file://$PROJECT_DIR$/spec/spec_helper.rb">
|
|
319
360
|
<provider selected="true" editor-type-id="text-editor">
|
|
320
|
-
<state line="
|
|
361
|
+
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
|
|
321
362
|
<folding />
|
|
322
363
|
</state>
|
|
323
364
|
</provider>
|
|
324
365
|
</entry>
|
|
325
|
-
<entry file="file://$PROJECT_DIR$/
|
|
366
|
+
<entry file="file://$PROJECT_DIR$/spec/mongoid/followable_spec.rb">
|
|
326
367
|
<provider selected="true" editor-type-id="text-editor">
|
|
327
|
-
<state line="
|
|
368
|
+
<state line="71" column="31" selection-start="1675" selection-end="1675" vertical-scroll-proportion="1.7959528">
|
|
328
369
|
<folding />
|
|
329
370
|
</state>
|
|
330
371
|
</provider>
|
|
331
372
|
</entry>
|
|
332
|
-
<entry file="file://$PROJECT_DIR$/
|
|
373
|
+
<entry file="file://$PROJECT_DIR$/app/models/follow.rb">
|
|
333
374
|
<provider selected="true" editor-type-id="text-editor">
|
|
334
|
-
<state line="
|
|
375
|
+
<state line="10" column="44" selection-start="315" selection-end="315" vertical-scroll-proportion="0.2529511">
|
|
335
376
|
<folding />
|
|
336
377
|
</state>
|
|
337
378
|
</provider>
|
|
338
379
|
</entry>
|
|
339
|
-
<entry file="file://$PROJECT_DIR$/lib/mongoid_followable.rb">
|
|
380
|
+
<entry file="file://$PROJECT_DIR$/lib/mongoid_followable/version.rb">
|
|
381
|
+
<provider selected="true" editor-type-id="text-editor">
|
|
382
|
+
<state line="2" column="20" selection-start="55" selection-end="55" vertical-scroll-proportion="0.05059022" />
|
|
383
|
+
</provider>
|
|
384
|
+
</entry>
|
|
385
|
+
<entry file="file://$PROJECT_DIR$/mongoid_followable.gemspec">
|
|
386
|
+
<provider selected="true" editor-type-id="text-editor">
|
|
387
|
+
<state line="11" column="66" selection-start="437" selection-end="437" vertical-scroll-proportion="0.2782462">
|
|
388
|
+
<folding />
|
|
389
|
+
</state>
|
|
390
|
+
</provider>
|
|
391
|
+
</entry>
|
|
392
|
+
<entry file="file://$PROJECT_DIR$/lib/mongoid_followable/followable.rb">
|
|
340
393
|
<provider selected="true" editor-type-id="text-editor">
|
|
341
|
-
<state line="
|
|
394
|
+
<state line="158" column="46" selection-start="3816" selection-end="3816" vertical-scroll-proportion="3.9966273">
|
|
342
395
|
<folding />
|
|
343
396
|
</state>
|
|
344
397
|
</provider>
|
data/README.rdoc
CHANGED
|
@@ -1,38 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
= mongoid_followable
|
|
2
|
+
|
|
3
|
+
== Installation
|
|
4
|
+
|
|
4
5
|
In console:
|
|
5
|
-
|
|
6
|
+
gem install mongoid_followable
|
|
6
7
|
or in Gemfile:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
gem 'mongoid_followable'
|
|
9
|
+
|
|
10
|
+
== Usage
|
|
11
|
+
|
|
10
12
|
To make model followable you need to include Mongoid::Followable into your document:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
class User
|
|
14
|
+
include Mongoid::Document
|
|
15
|
+
include Mongoid::Followable
|
|
16
|
+
end
|
|
15
17
|
Now you can follow others in your controller:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
...
|
|
19
|
+
@user = some_other_user
|
|
20
|
+
current_user.follow(@user)
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
current_user.unfollow(@user)
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
current_user.follower_of?(@user)
|
|
25
|
+
current_user.followee_of?(@user)
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
current_user.follower_count
|
|
28
|
+
current_user.followee_count
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
User.followers_of(current_user)
|
|
31
|
+
User.followees_of(current_user)
|
|
32
|
+
...
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
* In current version, only following the same model is allowed
|
|
35
|
+
|
|
36
|
+
== TODO
|
|
37
|
+
|
|
38
|
+
* inter-models followable
|
|
39
|
+
* divide into two parts: followable(being followed) and follower(following others)
|
|
40
|
+
* following history/followed history
|
|
41
|
+
* most/least followed/following
|
|
42
|
+
* follow part of user like only names etc(is this necessary?)
|
|
33
43
|
|
|
34
|
-
|
|
35
|
-
inter-models followable
|
|
44
|
+
== Copyright
|
|
36
45
|
|
|
37
|
-
|
|
38
|
-
Copyright © Jie Fan. See LICENSE.txt for further details.
|
|
46
|
+
Copyright (c) Jie Fan. See LICENSE.txt for further details.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
class Follow
|
|
2
|
+
include Mongoid::Document
|
|
3
|
+
|
|
4
|
+
field :f_type, :type => String
|
|
5
|
+
field :f_id, :type => String
|
|
6
|
+
|
|
7
|
+
belongs_to :followable, :polymorphic => true
|
|
8
|
+
belongs_to :following, :polymorphic => true
|
|
9
|
+
|
|
10
|
+
scope :by_type, lambda { |type| where(:f_type => type.capitalize) }
|
|
11
|
+
scope :by_model, lambda { |model| where(:f_id => model.id.to_s).by_type(model.class.name) }
|
|
12
|
+
end
|
data/lib/mongoid_followable.rb
CHANGED
|
@@ -1,151 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
extend ActiveSupport::Concern
|
|
4
|
-
|
|
5
|
-
included do |base|
|
|
6
|
-
base.field :follower, :type => Array, :default => []
|
|
7
|
-
base.field :followee, :type => Array, :default => []
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
module ClassMethods
|
|
11
|
-
# get a list of followers of certain model
|
|
12
|
-
#
|
|
13
|
-
# Example:
|
|
14
|
-
# >> @Jim = User.new
|
|
15
|
-
# >> @Tom = User.new
|
|
16
|
-
# >> @Jim.save
|
|
17
|
-
# >> @Tom.save
|
|
18
|
-
# >> @Jim.follow(@Tom)
|
|
19
|
-
# >> User.followers_of(@Tom)
|
|
20
|
-
# => [@Jim]
|
|
21
|
-
#
|
|
22
|
-
# Arguments:
|
|
23
|
-
# model: (instance of model(like User, Group))
|
|
24
|
-
def followers_of(model)
|
|
25
|
-
self.any_in(:_id => model.follower)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# get a list of followees of certain model
|
|
29
|
-
#
|
|
30
|
-
# Example:
|
|
31
|
-
# >> @Jim = User.new
|
|
32
|
-
# >> @Tom = User.new
|
|
33
|
-
# >> @Jim.save
|
|
34
|
-
# >> @Tom.save
|
|
35
|
-
# >> @Jim.follow(@Tom)
|
|
36
|
-
# >> User.followees_of(@Jim)
|
|
37
|
-
# => [@Tom]
|
|
38
|
-
#
|
|
39
|
-
# Arguments:
|
|
40
|
-
# model: (instance of model(like User, Group))
|
|
41
|
-
def followees_of(model)
|
|
42
|
-
self.any_in(:_id => model.followee)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
# judge whether a model is follower of another model
|
|
47
|
-
#
|
|
48
|
-
# Example:
|
|
49
|
-
# >> @Jim = User.new
|
|
50
|
-
# >> @Tom = User.new
|
|
51
|
-
# >> @Jim.save
|
|
52
|
-
# >> @Tom.save
|
|
53
|
-
# >> @Jim.follow(@Tom)
|
|
54
|
-
# >> @Jim.follower_of?(@Tom)
|
|
55
|
-
# => true
|
|
56
|
-
#
|
|
57
|
-
# Arguments:
|
|
58
|
-
# model: (instance of model(like User, Group))
|
|
59
|
-
def follower_of?(model)
|
|
60
|
-
return true if model.follower.include?(self.id) and self.followee.include?(model.id)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# judge whether a model is followee of another model
|
|
64
|
-
#
|
|
65
|
-
# Example:
|
|
66
|
-
# >> @Jim = User.new
|
|
67
|
-
# >> @Tom = User.new
|
|
68
|
-
# >> @Jim.save
|
|
69
|
-
# >> @Tom.save
|
|
70
|
-
# >> @Jim.follow(@Tom)
|
|
71
|
-
# >> @Tom.followee_of?(@Jim)
|
|
72
|
-
# => true
|
|
73
|
-
#
|
|
74
|
-
# Arguments:
|
|
75
|
-
# model: (instance of model(like User, Group))
|
|
76
|
-
def followee_of?(model)
|
|
77
|
-
return true if model.followee.include?(self.id) and self.follower.include?(model.id)
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
# follow a model
|
|
81
|
-
#
|
|
82
|
-
# Example:
|
|
83
|
-
# >> @Jim = User.new
|
|
84
|
-
# >> @Tom = User.new
|
|
85
|
-
# >> @Jim.save
|
|
86
|
-
# >> @Tom.save
|
|
87
|
-
# >> @Jim.follow(@Tom)
|
|
88
|
-
#
|
|
89
|
-
# Arguments:
|
|
90
|
-
# model: (instance of model(like User, Group))
|
|
91
|
-
def follow(model)
|
|
92
|
-
unless model == self
|
|
93
|
-
model.follower |= [self.id]
|
|
94
|
-
self.followee |= [model.id]
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
# cancel following a model
|
|
99
|
-
#
|
|
100
|
-
# Example:
|
|
101
|
-
# >> @Jim = User.new
|
|
102
|
-
# >> @Tom = User.new
|
|
103
|
-
# >> @Jim.save
|
|
104
|
-
# >> @Tom.save
|
|
105
|
-
# >> @Jim.follow(@Tom)
|
|
106
|
-
# >> @Jim.unfollow(@Tom)
|
|
107
|
-
#
|
|
108
|
-
# Arguments:
|
|
109
|
-
# model: (instance of model(like User, Group))
|
|
110
|
-
def unfollow(model)
|
|
111
|
-
unless model == self
|
|
112
|
-
model.follower -= [self.id]
|
|
113
|
-
self.followee -= [model.id]
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
# count followers of a model
|
|
118
|
-
#
|
|
119
|
-
# Example:
|
|
120
|
-
# >> @Jim = User.new
|
|
121
|
-
# >> @Tom = User.new
|
|
122
|
-
# >> @Jim.save
|
|
123
|
-
# >> @Tom.save
|
|
124
|
-
# >> @Jim.follow(@Tom)
|
|
125
|
-
# >> @Tom.follower_count
|
|
126
|
-
# => 1
|
|
127
|
-
#
|
|
128
|
-
# Arguments:
|
|
129
|
-
# none
|
|
130
|
-
def follower_count
|
|
131
|
-
self.follower.length
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
# count followees of a model
|
|
135
|
-
#
|
|
136
|
-
# Example:
|
|
137
|
-
# >> @Jim = User.new
|
|
138
|
-
# >> @Tom = User.new
|
|
139
|
-
# >> @Jim.save
|
|
140
|
-
# >> @Tom.save
|
|
141
|
-
# >> @Jim.follow(@Tom)
|
|
142
|
-
# >> @Jim.followee_count
|
|
143
|
-
# => 1
|
|
144
|
-
#
|
|
145
|
-
# Arguments:
|
|
146
|
-
# none
|
|
147
|
-
def followee_count
|
|
148
|
-
self.followee.length
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
end
|
|
1
|
+
require File.join(File.dirname(__FILE__), "mongoid_followable/followable")
|
|
2
|
+
require File.join(File.dirname(__FILE__), "../app/models/follow")
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
module Mongoid
|
|
2
|
+
module Followable
|
|
3
|
+
extend ActiveSupport::Concern
|
|
4
|
+
|
|
5
|
+
included do |base|
|
|
6
|
+
base.has_many :followers, :class_name => "Follow", :as => :followable, :dependent => :destroy
|
|
7
|
+
base.has_many :followees, :class_name => "Follow", :as => :following, :dependent => :destroy
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
module ClassMethods
|
|
11
|
+
|
|
12
|
+
# get certain model's followers of this type
|
|
13
|
+
#
|
|
14
|
+
# Example:
|
|
15
|
+
# >> @jim = User.new
|
|
16
|
+
# >> @ruby = Group.new
|
|
17
|
+
# >> @jim.save
|
|
18
|
+
# >> @ruby.save
|
|
19
|
+
#
|
|
20
|
+
# >> @jim.follow(@ruby)
|
|
21
|
+
# >> User.followers_of(@ruby)
|
|
22
|
+
# => [@jim]
|
|
23
|
+
#
|
|
24
|
+
# Arguments:
|
|
25
|
+
# model: instance of some followable model
|
|
26
|
+
|
|
27
|
+
def followers_of(model)
|
|
28
|
+
model.followers_by_type(self.name)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# get certain model's followees of this type
|
|
32
|
+
#
|
|
33
|
+
# Example:
|
|
34
|
+
# >> @jim.follow(@ruby)
|
|
35
|
+
# >> Group.followees_of(@jim)
|
|
36
|
+
# => [@ruby]
|
|
37
|
+
|
|
38
|
+
def followees_of(model)
|
|
39
|
+
model.followees_by_type(self.name)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# see if this model is follower of some model
|
|
45
|
+
#
|
|
46
|
+
# Example:
|
|
47
|
+
# >> @jim.follower_of?(@ruby)
|
|
48
|
+
# => true
|
|
49
|
+
|
|
50
|
+
def follower_of?(model)
|
|
51
|
+
0 < self.followees.by_model(model).limit(1).count * model.followers.by_model(self).limit(1).count
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# see if this model is followee of some model
|
|
55
|
+
#
|
|
56
|
+
# Example:
|
|
57
|
+
# >> @ruby.followee_of?(@jim)
|
|
58
|
+
# => true
|
|
59
|
+
|
|
60
|
+
def followee_of?(model)
|
|
61
|
+
0 < self.followers.by_model(model).limit(1).count * model.followees.by_model(self).limit(1).count
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# get all the followers of this model, same with classmethod followers_of
|
|
65
|
+
#
|
|
66
|
+
# Example:
|
|
67
|
+
# >> @ruby.all_followers
|
|
68
|
+
# => [@jim]
|
|
69
|
+
|
|
70
|
+
def all_followers
|
|
71
|
+
rebuild_instances(self.followers)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# get all the followees of this model, same with classmethod followees_of
|
|
75
|
+
#
|
|
76
|
+
# Example:
|
|
77
|
+
# >> @jim.all_followees
|
|
78
|
+
# => [@ruby]
|
|
79
|
+
|
|
80
|
+
def all_followees
|
|
81
|
+
rebuild_instances(self.followees)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# get all the followers of this model in certain type
|
|
85
|
+
#
|
|
86
|
+
# Example:
|
|
87
|
+
# >> @ruby.followers_by_type("user")
|
|
88
|
+
# => [@jim]
|
|
89
|
+
|
|
90
|
+
def followers_by_type(type)
|
|
91
|
+
rebuild_instances(self.followers.by_type(type))
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# get all the followees of this model in certain type
|
|
95
|
+
#
|
|
96
|
+
# Example:
|
|
97
|
+
# >> @ruby.followees_by_type("group")
|
|
98
|
+
# => [@ruby]
|
|
99
|
+
|
|
100
|
+
def followees_by_type(type)
|
|
101
|
+
rebuild_instances(self.followees.by_type(type))
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# follow some model
|
|
105
|
+
|
|
106
|
+
def follow(*models)
|
|
107
|
+
models.each do |model|
|
|
108
|
+
unless model == self or self.follower_of?(model) or model.followee_of?(self)
|
|
109
|
+
model.followers.create!(:f_type => self.class.name, :f_id => self.id.to_s)
|
|
110
|
+
self.followees.create!(:f_type => model.class.name, :f_id => model.id.to_s)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# unfollow some model
|
|
116
|
+
|
|
117
|
+
def unfollow(*models)
|
|
118
|
+
models.each do |model|
|
|
119
|
+
unless model == self or !self.follower_of?(model) or !model.followee_of?(self)
|
|
120
|
+
model.followers.by_model(self).first.destroy
|
|
121
|
+
self.followees.by_model(model).first.destroy
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# get the number of followers
|
|
127
|
+
#
|
|
128
|
+
# Example:
|
|
129
|
+
# >> @ruby.followers_count
|
|
130
|
+
# => 1
|
|
131
|
+
|
|
132
|
+
def followers_count
|
|
133
|
+
self.followers.count
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# get the number of followees
|
|
137
|
+
#
|
|
138
|
+
# Example:
|
|
139
|
+
# >> @jim.followers_count
|
|
140
|
+
# => 1
|
|
141
|
+
|
|
142
|
+
def followees_count
|
|
143
|
+
self.followees.count
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# get the number of followers in certain type
|
|
147
|
+
#
|
|
148
|
+
# Example:
|
|
149
|
+
# >> @ruby.followers_count_by_type("user")
|
|
150
|
+
# => 1
|
|
151
|
+
|
|
152
|
+
def followers_count_by_type(type)
|
|
153
|
+
self.followers.by_type(type).count
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# get the number of followees in certain type
|
|
157
|
+
#
|
|
158
|
+
# Example:
|
|
159
|
+
# >> @jim.followees_count_by_type("group")
|
|
160
|
+
# => 1
|
|
161
|
+
|
|
162
|
+
def followees_count_by_type(type)
|
|
163
|
+
self.followees.by_type(type).count
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
private
|
|
167
|
+
def rebuild_instances(follows)
|
|
168
|
+
follow_list = []
|
|
169
|
+
follows.each do |follow|
|
|
170
|
+
follow_list << follow.f_type.capitalize.constantize.find(follow.f_id)
|
|
171
|
+
end
|
|
172
|
+
follow_list
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|
data/mongoid_followable.gemspec
CHANGED
|
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
|
|
|
6
6
|
s.name = "mongoid_followable"
|
|
7
7
|
s.version = Mongoid::Followable::VERSION
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
|
9
|
-
s.date = "2011-06-
|
|
9
|
+
s.date = "2011-06-22"
|
|
10
10
|
s.authors = ["Jie Fan"]
|
|
11
11
|
s.email = ["ustc.flyingfox@gmail.com"]
|
|
12
12
|
s.homepage = "https://github.com/lastomato/mongoid_followable"
|
|
@@ -1,70 +1,98 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
describe Mongoid::Followable do
|
|
4
|
+
|
|
4
5
|
describe User do
|
|
5
6
|
|
|
6
7
|
let!(:u) { User.new }
|
|
7
8
|
|
|
8
|
-
context "
|
|
9
|
+
context "begins" do
|
|
9
10
|
|
|
10
11
|
before do
|
|
11
12
|
u.save
|
|
13
|
+
|
|
12
14
|
@v = User.new
|
|
13
15
|
@v.save
|
|
16
|
+
|
|
17
|
+
@g = Group.new
|
|
18
|
+
@g.save
|
|
14
19
|
end
|
|
15
20
|
|
|
16
|
-
it "
|
|
21
|
+
it "following a user" do
|
|
17
22
|
u.follow(@v)
|
|
18
|
-
u.followee.include?(@v.id).should be_true
|
|
19
|
-
@v.follower.include?(u.id).should be_true
|
|
20
23
|
|
|
21
24
|
u.follower_of?(@v).should be_true
|
|
22
|
-
u.followee_of?(@v).should be_false
|
|
23
|
-
@v.follower_of?(u).should be_false
|
|
24
25
|
@v.followee_of?(u).should be_true
|
|
25
26
|
|
|
26
|
-
u.
|
|
27
|
-
@v.
|
|
28
|
-
@v.follower_of?(@v).should be_false
|
|
29
|
-
u.followee_of?(u).should be_false
|
|
27
|
+
u.all_followees.should == [@v]
|
|
28
|
+
@v.all_followers.should == [u]
|
|
30
29
|
|
|
31
|
-
u.
|
|
32
|
-
@v.
|
|
33
|
-
u.followee_count.should == 1
|
|
34
|
-
@v.followee_count.should == 0
|
|
30
|
+
u.followees_by_type("user").should == [@v]
|
|
31
|
+
@v.followers_by_type("user").should == [u]
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
u.followees_count.should == 1
|
|
34
|
+
@v.followers_count.should == 1
|
|
35
|
+
|
|
36
|
+
u.followees_count_by_type("user").should == 1
|
|
37
|
+
@v.followers_count_by_type("user").should == 1
|
|
40
38
|
end
|
|
41
39
|
|
|
42
|
-
it "
|
|
40
|
+
it "unfollowing a user" do
|
|
43
41
|
u.unfollow(@v)
|
|
44
|
-
u.followee.include?(@v.id).should be_false
|
|
45
|
-
@v.follower.include?(u.id).should be_false
|
|
46
42
|
|
|
47
43
|
u.follower_of?(@v).should be_false
|
|
48
|
-
u.followee_of?(@v).should be_false
|
|
49
|
-
@v.follower_of?(u).should be_false
|
|
50
44
|
@v.followee_of?(u).should be_false
|
|
51
45
|
|
|
52
|
-
u.
|
|
53
|
-
@v.
|
|
54
|
-
|
|
55
|
-
u.
|
|
46
|
+
u.all_followees.should == []
|
|
47
|
+
@v.all_followers.should == []
|
|
48
|
+
|
|
49
|
+
u.followees_by_type("user").should == []
|
|
50
|
+
@v.followers_by_type("user").should == []
|
|
51
|
+
|
|
52
|
+
u.followees_count.should == 0
|
|
53
|
+
@v.followers_count.should == 0
|
|
54
|
+
|
|
55
|
+
u.followees_count_by_type("user").should == 0
|
|
56
|
+
@v.followers_count_by_type("user").should == 0
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "following a group" do
|
|
60
|
+
u.follow(@g)
|
|
56
61
|
|
|
57
|
-
u.
|
|
58
|
-
@
|
|
59
|
-
u.followee_count.should == 0
|
|
60
|
-
@v.followee_count.should == 0
|
|
62
|
+
u.follower_of?(@g).should be_true
|
|
63
|
+
@g.followee_of?(u).should be_true
|
|
61
64
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
u.all_followees.should == [@g]
|
|
66
|
+
@g.all_followers.should == [u]
|
|
67
|
+
|
|
68
|
+
u.followees_by_type("group").should == [@g]
|
|
69
|
+
@g.followers_by_type("user").should == [u]
|
|
70
|
+
|
|
71
|
+
u.followees_count.should == 1
|
|
72
|
+
@g.followers_count.should == 1
|
|
73
|
+
|
|
74
|
+
u.followees_count_by_type("group").should == 1
|
|
75
|
+
@g.followers_count_by_type("user").should == 1
|
|
66
76
|
end
|
|
67
77
|
|
|
78
|
+
it "unfollowing a group" do
|
|
79
|
+
u.unfollow(@g)
|
|
80
|
+
|
|
81
|
+
u.follower_of?(@g).should be_false
|
|
82
|
+
@g.followee_of?(u).should be_false
|
|
83
|
+
|
|
84
|
+
u.all_followees.should == []
|
|
85
|
+
@g.all_followers.should == []
|
|
86
|
+
|
|
87
|
+
u.followees_by_type("group").should == []
|
|
88
|
+
@g.followers_by_type("group").should == []
|
|
89
|
+
|
|
90
|
+
u.followees_count.should == 0
|
|
91
|
+
@g.followers_count.should == 0
|
|
92
|
+
|
|
93
|
+
u.followees_count_by_type("group").should == 0
|
|
94
|
+
@g.followers_count_by_type("group").should == 0
|
|
95
|
+
end
|
|
68
96
|
end
|
|
69
97
|
end
|
|
70
98
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -11,8 +11,8 @@ Mongoid.configure do |config|
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
require File.expand_path("../../lib/mongoid_followable", __FILE__)
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
require File.expand_path("../models/user", __FILE__)
|
|
15
|
+
require File.expand_path("../models/group", __FILE__)
|
|
16
16
|
|
|
17
17
|
RSpec.configure do |c|
|
|
18
18
|
c.before(:all) { DatabaseCleaner.strategy = :truncation }
|
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: mongoid_followable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 0.0
|
|
5
|
+
version: 0.1.0
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Jie Fan
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date: 2011-06-
|
|
13
|
+
date: 2011-06-22 00:00:00 -04:00
|
|
14
14
|
default_executable:
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
@@ -81,9 +81,12 @@ files:
|
|
|
81
81
|
- README
|
|
82
82
|
- README.rdoc
|
|
83
83
|
- Rakefile
|
|
84
|
+
- app/models/follow.rb
|
|
84
85
|
- lib/mongoid_followable.rb
|
|
86
|
+
- lib/mongoid_followable/followable.rb
|
|
85
87
|
- lib/mongoid_followable/version.rb
|
|
86
88
|
- mongoid_followable.gemspec
|
|
89
|
+
- spec/models/group.rb
|
|
87
90
|
- spec/models/user.rb
|
|
88
91
|
- spec/mongoid/followable_spec.rb
|
|
89
92
|
- spec/spec_helper.rb
|