social_stream 0.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/Gemfile.lock +48 -44
  2. data/app/controllers/ties_controller.rb +1 -0
  3. data/app/models/ability.rb +2 -0
  4. data/app/models/actor.rb +7 -8
  5. data/app/models/permission.rb +80 -0
  6. data/app/models/relation.rb +1 -6
  7. data/app/models/tie.rb +34 -42
  8. data/app/views/activities/_child.html.erb +1 -2
  9. data/app/views/activities/_jquery.html.erb +2 -3
  10. data/app/views/activities/_options.html.erb +1 -1
  11. data/app/views/activities/_root.html.erb +1 -2
  12. data/app/views/comments/_new.html.erb +18 -15
  13. data/app/views/groups/_followers.html.erb +16 -14
  14. data/app/views/groups/_group.html.erb +1 -1
  15. data/app/views/groups/_location.html.erb +3 -0
  16. data/app/views/groups/show.html.erb +2 -2
  17. data/app/views/home/_contacts.html.erb +2 -2
  18. data/app/views/home/_groups.html.erb +23 -0
  19. data/app/views/home/_options.html.erb +0 -6
  20. data/app/views/home/_right.html.erb +1 -6
  21. data/app/views/home/index.html.erb +3 -3
  22. data/app/views/posts/_post.html.erb +1 -1
  23. data/app/views/ties/_suggestions.html.erb +7 -1
  24. data/app/views/ties/_tie.html.erb +1 -1
  25. data/app/views/users/_contacts.html.erb +16 -18
  26. data/app/views/users/_groups.html.erb +1 -2
  27. data/app/views/users/_location.html.erb +3 -0
  28. data/app/views/users/_logo.html.erb +2 -4
  29. data/app/views/users/_menu.html.erb +3 -26
  30. data/app/views/users/_middle_show.html.erb +0 -1
  31. data/app/views/users/_options.html.erb +5 -0
  32. data/app/views/users/_right_show.html.erb +9 -0
  33. data/app/views/users/show.html.erb +2 -2
  34. data/config/locales/en.yml +3 -2
  35. data/lib/generators/social_stream/templates/public/images/btn/{btn_follower.png → btn_group.png} +0 -0
  36. data/lib/generators/social_stream/templates/public/images/logos/actor/group.png +0 -0
  37. data/lib/generators/social_stream/templates/public/images/logos/actor/user.png +0 -0
  38. data/lib/generators/social_stream/templates/public/images/logos/original/group.png +0 -0
  39. data/lib/generators/social_stream/templates/public/images/logos/original/user.png +0 -0
  40. data/lib/generators/social_stream/templates/public/images/logos/profile/group.png +0 -0
  41. data/lib/generators/social_stream/templates/public/images/logos/profile/user.png +0 -0
  42. data/lib/generators/social_stream/templates/public/images/logos/tie/group.png +0 -0
  43. data/lib/generators/social_stream/templates/public/images/logos/tie/user.png +0 -0
  44. data/lib/generators/social_stream/templates/public/images/{btn/title_background.png → title_background.png} +0 -0
  45. data/lib/generators/social_stream/templates/public/stylesheets/middle.css +1 -1
  46. data/lib/generators/social_stream/templates/public/stylesheets/right.css +1 -0
  47. data/lib/generators/social_stream/templates/seeds.yml +20 -20
  48. data/lib/social_stream/ability.rb +26 -0
  49. data/lib/social_stream/version.rb +1 -1
  50. data/lib/tasks/db/populate.rake +25 -6
  51. data/social_stream.gemspec +2 -1
  52. data/spec/dummy/db/seeds/social_stream.yml +43 -33
  53. data/spec/factories/tie.rb +15 -10
  54. data/spec/models/activity_spec.rb +83 -146
  55. data/spec/models/tie_spec.rb +113 -0
  56. metadata +52 -25
  57. data/spec/dummy/app/models/ability.rb +0 -23
@@ -26,5 +26,118 @@ describe Tie do
26
26
  @relation.inverse).present?
27
27
  end
28
28
  end
29
+
30
+ describe "friend" do
31
+ before do
32
+ @tie = Factory(:friend)
33
+ end
34
+
35
+ describe ", sender" do
36
+ before do
37
+ @s = @tie.sender
38
+ end
39
+
40
+ it "creates activity" do
41
+ Tie.allowed(@s, 'create', 'activity').should include(@tie)
42
+ Tie.allowed(@s, 'create', 'activity').should include(@tie.related('public'))
43
+ Tie.allowed(@s, 'create', 'activity').should_not include(@tie.inverse)
44
+ Tie.allowed(@s, 'create', 'activity').should_not include(@tie.inverse.related('public'))
45
+ end
46
+
47
+ it "reads activity" do
48
+ Tie.allowed(@s, 'read', 'activity').should include(@tie)
49
+ Tie.allowed(@s, 'read', 'activity').should include(@tie.related('public'))
50
+ Tie.allowed(@s, 'read', 'activity').should include(@tie.inverse)
51
+ Tie.allowed(@s, 'read', 'activity').should include(@tie.inverse.related('public'))
52
+ end
53
+ end
54
+
55
+ describe ", friend" do
56
+ before do
57
+ @s = @tie.receiver
58
+ end
59
+
60
+ it "creates activity" do
61
+ Tie.allowed(@s, 'create', 'activity').should include(@tie.inverse)
62
+ Tie.allowed(@s, 'create', 'activity').should include(@tie.inverse.related('public'))
63
+ Tie.allowed(@s, 'create', 'activity').should_not include(@tie)
64
+ Tie.allowed(@s, 'create', 'activity').should_not include(@tie.related('public'))
65
+ end
66
+
67
+ it "reads activity" do
68
+ Tie.allowed(@s, 'read', 'activity').should include(@tie)
69
+ Tie.allowed(@s, 'read', 'activity').should include(@tie.related('public'))
70
+ Tie.allowed(@s, 'read', 'activity').should include(@tie.inverse)
71
+ Tie.allowed(@s, 'read', 'activity').should include(@tie.inverse.related('public'))
72
+ end
73
+ end
74
+
75
+ describe ", friend request" do
76
+ before do
77
+ @s = Factory(:friend_request, :receiver => @tie.receiver).sender
78
+ end
79
+
80
+ it "creates activity" do
81
+ Tie.allowed(@s, 'create', 'activity').should_not include(@tie)
82
+ Tie.allowed(@s, 'create', 'activity').should_not include(@tie.related('public'))
83
+ Tie.allowed(@s, 'create', 'activity').should_not include(@tie.inverse)
84
+ Tie.allowed(@s, 'create', 'activity').should_not include(@tie.inverse.related('public'))
85
+ end
86
+
87
+ it "reads activity" do
88
+ Tie.allowed(@s, 'read', 'activity').should_not include(@tie)
89
+ # Tie.allowed(@s, 'read', 'activity').should_not include(@tie.related('public'))
90
+ Tie.allowed(@s, 'read', 'activity').should_not include(@tie.inverse)
91
+ # Tie.allowed(@s, 'read', 'activity').should_not include(@tie.inverse.related('public'))
92
+ end
93
+
94
+ end
95
+
96
+ describe ", alien" do
97
+ before do
98
+ @s = Factory(:user)
99
+ end
100
+
101
+ it "creates activity" do
102
+ Tie.allowed(@s, 'create', 'activity').should_not include(@tie)
103
+ Tie.allowed(@s, 'create', 'activity').should_not include(@tie.related('public'))
104
+ Tie.allowed(@s, 'create', 'activity').should_not include(@tie.inverse)
105
+ Tie.allowed(@s, 'create', 'activity').should_not include(@tie.inverse.related('public'))
106
+ end
107
+
108
+ it "reads activity" do
109
+ Tie.allowed(@s, 'read', 'activity').should_not include(@tie)
110
+ Tie.allowed(@s, 'read', 'activity').should_not include(@tie.inverse)
111
+ end
112
+ end
113
+ end
114
+
115
+ describe "member" do
116
+ before do
117
+ @tie = Factory(:member)
118
+ end
119
+
120
+ describe ", sender" do
121
+ before do
122
+ @s = @tie.sender
123
+ end
124
+
125
+ it "updates activity" do
126
+ Tie.allowed(@s, 'update', 'activity').should include(@tie)
127
+ Tie.allowed(@s, 'update', 'activity').should include(@tie.related('public'))
128
+ end
129
+ end
130
+
131
+ describe ", member" do
132
+ before do
133
+ @s = Factory(:member, :receiver => @tie.receiver).sender
134
+ end
135
+
136
+ it "updates activity" do
137
+ Tie.allowed(@s, 'update', 'activity').should include(@tie)
138
+ Tie.allowed(@s, 'update', 'activity').should include(@tie.related('public'))
139
+ end
140
+ end
141
+ end
29
142
  end
30
143
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_stream
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 7
10
- version: 0.1.7
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Antonio Tapiador
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-11-11 00:00:00 +01:00
19
+ date: 2010-11-17 00:00:00 +01:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -164,25 +164,41 @@ dependencies:
164
164
  type: :runtime
165
165
  version_requirements: *id009
166
166
  - !ruby/object:Gem::Dependency
167
- name: rails
167
+ name: will_paginate
168
168
  prerelease: false
169
169
  requirement: &id010 !ruby/object:Gem::Requirement
170
170
  none: false
171
171
  requirements:
172
172
  - - ~>
173
173
  - !ruby/object:Gem::Version
174
- hash: 5
174
+ hash: 29
175
+ segments:
176
+ - 2
177
+ - 3
178
+ - 15
179
+ version: 2.3.15
180
+ type: :runtime
181
+ version_requirements: *id010
182
+ - !ruby/object:Gem::Dependency
183
+ name: rails
184
+ prerelease: false
185
+ requirement: &id011 !ruby/object:Gem::Requirement
186
+ none: false
187
+ requirements:
188
+ - - ~>
189
+ - !ruby/object:Gem::Version
190
+ hash: 1
175
191
  segments:
176
192
  - 3
177
193
  - 0
178
- - 1
179
- version: 3.0.1
194
+ - 3
195
+ version: 3.0.3
180
196
  type: :development
181
- version_requirements: *id010
197
+ version_requirements: *id011
182
198
  - !ruby/object:Gem::Dependency
183
199
  name: capybara
184
200
  prerelease: false
185
- requirement: &id011 !ruby/object:Gem::Requirement
201
+ requirement: &id012 !ruby/object:Gem::Requirement
186
202
  none: false
187
203
  requirements:
188
204
  - - ~>
@@ -194,11 +210,11 @@ dependencies:
194
210
  - 9
195
211
  version: 0.3.9
196
212
  type: :development
197
- version_requirements: *id011
213
+ version_requirements: *id012
198
214
  - !ruby/object:Gem::Dependency
199
215
  name: sqlite3-ruby
200
216
  prerelease: false
201
- requirement: &id012 !ruby/object:Gem::Requirement
217
+ requirement: &id013 !ruby/object:Gem::Requirement
202
218
  none: false
203
219
  requirements:
204
220
  - - ">="
@@ -208,11 +224,11 @@ dependencies:
208
224
  - 0
209
225
  version: "0"
210
226
  type: :development
211
- version_requirements: *id012
227
+ version_requirements: *id013
212
228
  - !ruby/object:Gem::Dependency
213
229
  name: ruby-debug
214
230
  prerelease: false
215
- requirement: &id013 !ruby/object:Gem::Requirement
231
+ requirement: &id014 !ruby/object:Gem::Requirement
216
232
  none: false
217
233
  requirements:
218
234
  - - ~>
@@ -224,11 +240,11 @@ dependencies:
224
240
  - 3
225
241
  version: 0.10.3
226
242
  type: :development
227
- version_requirements: *id013
243
+ version_requirements: *id014
228
244
  - !ruby/object:Gem::Dependency
229
245
  name: rspec-rails
230
246
  prerelease: false
231
- requirement: &id014 !ruby/object:Gem::Requirement
247
+ requirement: &id015 !ruby/object:Gem::Requirement
232
248
  none: false
233
249
  requirements:
234
250
  - - ~>
@@ -240,11 +256,11 @@ dependencies:
240
256
  - 0
241
257
  version: 2.0.0
242
258
  type: :development
243
- version_requirements: *id014
259
+ version_requirements: *id015
244
260
  - !ruby/object:Gem::Dependency
245
261
  name: factory_girl
246
262
  prerelease: false
247
- requirement: &id015 !ruby/object:Gem::Requirement
263
+ requirement: &id016 !ruby/object:Gem::Requirement
248
264
  none: false
249
265
  requirements:
250
266
  - - ~>
@@ -256,11 +272,11 @@ dependencies:
256
272
  - 2
257
273
  version: 1.3.2
258
274
  type: :development
259
- version_requirements: *id015
275
+ version_requirements: *id016
260
276
  - !ruby/object:Gem::Dependency
261
277
  name: forgery
262
278
  prerelease: false
263
- requirement: &id016 !ruby/object:Gem::Requirement
279
+ requirement: &id017 !ruby/object:Gem::Requirement
264
280
  none: false
265
281
  requirements:
266
282
  - - ~>
@@ -272,7 +288,7 @@ dependencies:
272
288
  - 6
273
289
  version: 0.3.6
274
290
  type: :development
275
- version_requirements: *id016
291
+ version_requirements: *id017
276
292
  description: Ruby on Rails engine supporting social networking features and activity streams.
277
293
  email:
278
294
  executables: []
@@ -302,6 +318,7 @@ files:
302
318
  - app/helpers/groups_helper.rb
303
319
  - app/helpers/ties_helper.rb
304
320
  - app/helpers/users_helper.rb
321
+ - app/models/ability.rb
305
322
  - app/models/activity.rb
306
323
  - app/models/activity_object.rb
307
324
  - app/models/activity_object_activity.rb
@@ -336,6 +353,7 @@ files:
336
353
  - app/views/groups/_followers.html.erb
337
354
  - app/views/groups/_group.html.erb
338
355
  - app/views/groups/_index.html.erb
356
+ - app/views/groups/_location.html.erb
339
357
  - app/views/groups/_logo.html.erb
340
358
  - app/views/groups/_middle_index.html.erb
341
359
  - app/views/groups/_middle_show.html.erb
@@ -345,6 +363,7 @@ files:
345
363
  - app/views/groups/index.html.erb
346
364
  - app/views/groups/show.html.erb
347
365
  - app/views/home/_contacts.html.erb
366
+ - app/views/home/_groups.html.erb
348
367
  - app/views/home/_location.html.erb
349
368
  - app/views/home/_middle.html.erb
350
369
  - app/views/home/_options.html.erb
@@ -373,10 +392,12 @@ files:
373
392
  - app/views/users/_contacts.html.erb
374
393
  - app/views/users/_groups.html.erb
375
394
  - app/views/users/_index.html.erb
395
+ - app/views/users/_location.html.erb
376
396
  - app/views/users/_logo.html.erb
377
397
  - app/views/users/_menu.html.erb
378
398
  - app/views/users/_middle_index.html.erb
379
399
  - app/views/users/_middle_show.html.erb
400
+ - app/views/users/_options.html.erb
380
401
  - app/views/users/_profile.html.erb
381
402
  - app/views/users/_right_index.html.erb
382
403
  - app/views/users/_right_show.html.erb
@@ -415,10 +436,10 @@ files:
415
436
  - lib/generators/social_stream/templates/public/images/btn/btn_exit.png
416
437
  - lib/generators/social_stream/templates/public/images/btn/btn_find.png
417
438
  - lib/generators/social_stream/templates/public/images/btn/btn_follow.png
418
- - lib/generators/social_stream/templates/public/images/btn/btn_follower.png
419
439
  - lib/generators/social_stream/templates/public/images/btn/btn_foward.png
420
440
  - lib/generators/social_stream/templates/public/images/btn/btn_friend.png
421
441
  - lib/generators/social_stream/templates/public/images/btn/btn_gallery.png
442
+ - lib/generators/social_stream/templates/public/images/btn/btn_group.png
422
443
  - lib/generators/social_stream/templates/public/images/btn/btn_help.png
423
444
  - lib/generators/social_stream/templates/public/images/btn/btn_home.png
424
445
  - lib/generators/social_stream/templates/public/images/btn/btn_inbox.png
@@ -463,7 +484,6 @@ files:
463
484
  - lib/generators/social_stream/templates/public/images/btn/subtime.png
464
485
  - lib/generators/social_stream/templates/public/images/btn/tag_cloud.png
465
486
  - lib/generators/social_stream/templates/public/images/btn/time.png
466
- - lib/generators/social_stream/templates/public/images/btn/title_background.png
467
487
  - lib/generators/social_stream/templates/public/images/btn/uno.png
468
488
  - lib/generators/social_stream/templates/public/images/btn/viewer.png
469
489
  - lib/generators/social_stream/templates/public/images/frontpage/collaborate.gif
@@ -488,9 +508,16 @@ files:
488
508
  - lib/generators/social_stream/templates/public/images/frontpage/yellow_sq.png
489
509
  - lib/generators/social_stream/templates/public/images/left.png
490
510
  - lib/generators/social_stream/templates/public/images/logo.png
511
+ - lib/generators/social_stream/templates/public/images/logos/actor/group.png
512
+ - lib/generators/social_stream/templates/public/images/logos/actor/user.png
491
513
  - lib/generators/social_stream/templates/public/images/logos/original/group.png
492
514
  - lib/generators/social_stream/templates/public/images/logos/original/user.png
515
+ - lib/generators/social_stream/templates/public/images/logos/profile/group.png
516
+ - lib/generators/social_stream/templates/public/images/logos/profile/user.png
517
+ - lib/generators/social_stream/templates/public/images/logos/tie/group.png
518
+ - lib/generators/social_stream/templates/public/images/logos/tie/user.png
493
519
  - lib/generators/social_stream/templates/public/images/right.png
520
+ - lib/generators/social_stream/templates/public/images/title_background.png
494
521
  - lib/generators/social_stream/templates/public/images/ui-bg_flat_0_aaaaaa_40x100.png
495
522
  - lib/generators/social_stream/templates/public/images/ui-bg_flat_75_ffffff_40x100.png
496
523
  - lib/generators/social_stream/templates/public/images/ui-bg_glass_55_fbf9ee_1x400.png
@@ -542,6 +569,7 @@ files:
542
569
  - lib/generators/social_stream/templates/seeds.yml
543
570
  - lib/paperclip/social_stream.rb
544
571
  - lib/social_stream.rb
572
+ - lib/social_stream/ability.rb
545
573
  - lib/social_stream/models/activity_object.rb
546
574
  - lib/social_stream/models/actor.rb
547
575
  - lib/social_stream/models/supertype.rb
@@ -556,7 +584,6 @@ files:
556
584
  - spec/dummy/Rakefile
557
585
  - spec/dummy/app/controllers/application_controller.rb
558
586
  - spec/dummy/app/helpers/application_helper.rb
559
- - spec/dummy/app/models/ability.rb
560
587
  - spec/dummy/app/models/post.rb
561
588
  - spec/dummy/app/models/user.rb
562
589
  - spec/dummy/app/views/layouts/application.html.erb
@@ -1,23 +0,0 @@
1
- class Ability
2
- include CanCan::Ability
3
-
4
- def initialize(user)
5
- can :create, Activity do |a|
6
- # All ties authors must the user
7
- a.tie.sender_subject == user &&
8
- a.tie.permission?(user, 'create', 'resources')
9
- end
10
-
11
- can :read, Activity do |a|
12
- a.tie.permission?(user, 'read', 'resources')
13
- end
14
-
15
- can :update, Activity do |a|
16
- a.tie.permission?(user, 'update', 'resources')
17
- end
18
-
19
- can :destroy, Activity do |a|
20
- a.tie.permission?(user, 'destroy', 'resources')
21
- end
22
- end
23
- end