social_stream 0.4.2 → 0.4.3

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.
Files changed (78) hide show
  1. data/app/controllers/activities_controller.rb +1 -0
  2. data/app/controllers/avatars_controller.rb +17 -10
  3. data/app/controllers/comments_controller.rb +2 -0
  4. data/app/controllers/conversations_controller.rb +98 -103
  5. data/app/controllers/groups_controller.rb +3 -1
  6. data/app/controllers/likes_controller.rb +2 -0
  7. data/app/controllers/messages_controller.rb +4 -0
  8. data/app/controllers/posts_controller.rb +2 -2
  9. data/app/controllers/ties_controller.rb +6 -0
  10. data/app/helpers/subjects_helper.rb +32 -7
  11. data/app/helpers/ties_helper.rb +7 -2
  12. data/app/models/activity.rb +1 -1
  13. data/app/models/actor.rb +5 -8
  14. data/app/models/relation.rb +65 -0
  15. data/app/models/tie.rb +27 -7
  16. data/app/views/activities/_child.html.erb +1 -5
  17. data/app/views/activities/_root.html.erb +2 -4
  18. data/app/views/avatars/_form.html.erb +5 -16
  19. data/app/views/avatars/_precrop.html.erb +24 -17
  20. data/app/views/avatars/index.html.erb +47 -36
  21. data/app/views/avatars/new.html.erb +19 -3
  22. data/app/views/contacts/index.html.erb +1 -1
  23. data/app/views/contacts/index.js.erb +2 -0
  24. data/app/views/conversations/_conversation_full.html.erb +2 -1
  25. data/app/views/conversations/_index.html.erb +0 -7
  26. data/app/views/conversations/_show.html.erb +0 -7
  27. data/app/views/conversations/index.html.erb +9 -1
  28. data/app/views/conversations/index.js.erb +1 -0
  29. data/app/views/conversations/show.html.erb +1 -1
  30. data/app/views/conversations/show.js.erb +2 -0
  31. data/app/views/groups/_new.html.erb +9 -2
  32. data/app/views/groups/new.html.erb +5 -1
  33. data/app/views/layouts/_header.erb +23 -1
  34. data/app/views/layouts/_representation.html.erb +1 -1
  35. data/app/views/messages/new.html.erb +1 -1
  36. data/app/views/messages/new.js.erb +3 -0
  37. data/app/views/profiles/_profile.html.erb +18 -13
  38. data/app/views/profiles/edit.html.erb +29 -4
  39. data/app/views/profiles/update.js.erb +3 -3
  40. data/app/views/subjects/_toolbar_home_menu_options.html.erb +1 -1
  41. data/app/views/subjects/_toolbar_home_menu_options_subjects.html.erb +2 -2
  42. data/app/views/subjects/_toolbar_logo.html.erb +14 -2
  43. data/app/views/subjects/_toolbar_message_menu.html.erb +1 -1
  44. data/app/views/subjects/_toolbar_profile_menu_tie_options.html.erb +18 -7
  45. data/app/views/ties/_edit.html.erb +102 -0
  46. data/app/views/ties/_new.html.erb +48 -19
  47. data/app/views/ties/edit.html.erb +1 -0
  48. data/config/locales/en.yml +42 -27
  49. data/config/routes.rb +0 -6
  50. data/lib/generators/social_stream/templates/public/images/btn/arrowBlue.png +0 -0
  51. data/lib/generators/social_stream/templates/public/images/btn/shadow.png +0 -0
  52. data/lib/generators/social_stream/templates/public/javascripts/addContact.js +100 -0
  53. data/lib/generators/social_stream/templates/public/javascripts/avatars.js +8 -0
  54. data/lib/generators/social_stream/templates/public/javascripts/hoverIntent.js +84 -0
  55. data/lib/generators/social_stream/templates/public/javascripts/main.js +10 -1
  56. data/lib/generators/social_stream/templates/public/javascripts/menu.js +22 -6
  57. data/lib/generators/social_stream/templates/public/stylesheets/default/activities.css +2 -2
  58. data/lib/generators/social_stream/templates/public/stylesheets/default/addContact.css +29 -0
  59. data/lib/generators/social_stream/templates/public/stylesheets/default/avatars.css +79 -0
  60. data/lib/generators/social_stream/templates/public/stylesheets/default/base.css +44 -5
  61. data/lib/generators/social_stream/templates/public/stylesheets/default/header.css +151 -1
  62. data/lib/generators/social_stream/templates/public/stylesheets/default/home.css +1 -1
  63. data/lib/generators/social_stream/templates/public/stylesheets/default/jquery-ui.css +1 -1
  64. data/lib/generators/social_stream/templates/public/stylesheets/default/messages.css +6 -4
  65. data/lib/social_stream.rb +1 -1
  66. data/lib/social_stream/ability.rb +20 -0
  67. data/lib/social_stream/models/subject.rb +5 -1
  68. data/lib/social_stream/test_helpers/controllers.rb +55 -0
  69. data/lib/social_stream/version.rb +1 -1
  70. data/social_stream.gemspec +1 -1
  71. data/spec/controllers/comments_controller_spec.rb +38 -0
  72. data/spec/controllers/groups_controller_spec.rb +75 -5
  73. data/spec/factories/comment.rb +4 -0
  74. data/spec/models/tie_spec.rb +25 -15
  75. metadata +18 -10
  76. data/app/controllers/pshb_controller.rb +0 -55
  77. data/app/views/ties/new.js.erb +0 -12
  78. data/lib/social_stream/relations.rb +0 -46
data/lib/social_stream.rb CHANGED
@@ -52,7 +52,7 @@ module SocialStream
52
52
  #
53
53
  # Maybe Rails provides some method to do this, in this case, please tell!!
54
54
  def require_model(m)
55
- path = $:.find{ |f| f =~ Regexp.new(File.join('social_stream', 'app', 'models')) }
55
+ path = $:.find{ |f| f =~ Regexp.new(File.join('social_stream.*', 'app', 'models')) }
56
56
 
57
57
  raise "Can't find social_stream path" if path.blank?
58
58
 
@@ -24,6 +24,7 @@ module SocialStream
24
24
  end
25
25
  end
26
26
 
27
+ # Activities
27
28
  can :create, Activity do |a|
28
29
  a.tie.allows?(user, 'create', 'activity')
29
30
  end
@@ -39,6 +40,25 @@ module SocialStream
39
40
  can :destroy, Activity do |a|
40
41
  a.tie.allows?(user, 'destroy', 'activity')
41
42
  end
43
+
44
+ # Groups
45
+ can :read, Group
46
+
47
+ can :create, Group do |g|
48
+ user.present? &&
49
+ ( g._founder == user.slug ||
50
+ Actor.find_by_slug!(g._founder).sent_ties.received_by(user).with_permissions('represent', nil).any? )
51
+ end
52
+
53
+ can :update, Group do |g|
54
+ user.present? &&
55
+ g.sent_ties.received_by(user).with_permissions('represent', nil).any?
56
+ end
57
+
58
+ can :destroy, Group do |g|
59
+ user.present? &&
60
+ g.sent_ties.received_by(user).with_permissions('represent', nil).any?
61
+ end
42
62
  end
43
63
  end
44
64
  end
@@ -63,10 +63,14 @@ module SocialStream
63
63
  slug
64
64
  end
65
65
 
66
- # Delegate missing methods to {Actor}, if they are defined there
66
+ # Delegate missing methods to {Actor}, if they exist there
67
67
  def method_missing(method, *args, &block)
68
68
  super
69
69
  rescue NameError => subject_error
70
+ # These methods must be raised to avoid loops (the :actor association calls here again)
71
+ exceptions = [ :_actor_id ]
72
+ raise subject_error if exceptions.include?(method)
73
+
70
74
  actor!.__send__ method, *args, &block
71
75
  end
72
76
 
@@ -23,6 +23,10 @@ module SocialStream
23
23
  { model_sym => model_attributes }
24
24
  end
25
25
 
26
+ def updating_attributes
27
+ attributes.merge({ :id => @current_model.to_param })
28
+ end
29
+
26
30
  # Post.count
27
31
  def model_count
28
32
  model_class.count
@@ -59,6 +63,57 @@ module SocialStream
59
63
  resource.should be_new_record
60
64
  end
61
65
  end
66
+
67
+ shared_examples_for "Allow Updating" do
68
+ it "should update" do
69
+ put :update, updating_attributes
70
+
71
+ resource = assigns(model_sym)
72
+
73
+ resource.should_receive(:update_attributes).with(attributes)
74
+ assert resource.valid?
75
+ response.should redirect_to(resource)
76
+ end
77
+ end
78
+
79
+ shared_examples_for "Deny Updating" do
80
+ it "should not update" do
81
+ begin
82
+ put :update, updating_attributes
83
+ rescue CanCan::AccessDenied
84
+ end
85
+
86
+ resource = assigns(model_sym)
87
+
88
+ resource.should_not_receive(:update_attributes)
89
+ end
90
+ end
91
+
92
+ shared_examples_for "Allow Destroying" do
93
+ it "should destroy" do
94
+ count = model_count
95
+ delete :destroy, :id => @current_model.to_param
96
+
97
+ resource = assigns(model_sym)
98
+
99
+ model_count.should eq(count - 1)
100
+ end
101
+ end
102
+
103
+ shared_examples_for "Deny Destroying" do
104
+ it "should not destroy" do
105
+ count = model_count
106
+ begin
107
+ delete :destroy, :id => @current_model.to_param
108
+ rescue CanCan::AccessDenied
109
+ end
110
+
111
+ resource = assigns(model_sym)
112
+
113
+ model_count.should eq(count)
114
+ end
115
+ end
116
+
62
117
  end
63
118
  end
64
119
  end
@@ -1,3 +1,3 @@
1
1
  module SocialStream
2
- VERSION = "0.4.2".freeze
2
+ VERSION = "0.4.3".freeze
3
3
  end
@@ -45,7 +45,7 @@ Gem::Specification.new do |s|
45
45
 
46
46
 
47
47
  # Development Gem dependencies
48
- s.add_development_dependency('rails', '~> 3.0.5')
48
+ s.add_development_dependency('rails', '~> 3.0.6')
49
49
  # Integration testing
50
50
  s.add_development_dependency('capybara', '~> 0.3.9')
51
51
  # Testing database
@@ -0,0 +1,38 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe CommentsController do
4
+ include SocialStream::TestHelpers::Controllers
5
+
6
+ render_views
7
+
8
+ describe "authorizing" do
9
+ before do
10
+ @user = Factory(:user)
11
+ sign_in @user
12
+ end
13
+
14
+ describe "comment from user" do
15
+ before do
16
+ model_assigned_to @user.sent_ties.received_by(@user).related_by(@user.relations.sort.first).first
17
+ end
18
+
19
+ it_should_behave_like "Allow Creating"
20
+ end
21
+
22
+ describe "comment from friend" do
23
+ before do
24
+ model_assigned_to Factory(:friend, :receiver => @user.actor)
25
+ end
26
+
27
+ it_should_behave_like "Allow Creating"
28
+ end
29
+
30
+ describe "post from acquaintance" do
31
+ before do
32
+ model_assigned_to Factory(:acquaintance, :receiver => @user.actor)
33
+ end
34
+
35
+ it_should_behave_like "Deny Creating"
36
+ end
37
+ end
38
+ end
@@ -1,6 +1,8 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe GroupsController do
4
+ include SocialStream::TestHelpers::Controllers
5
+
4
6
  render_views
5
7
 
6
8
  describe "when Anonymous" do
@@ -15,6 +17,33 @@ describe GroupsController do
15
17
 
16
18
  assert_response :success
17
19
  end
20
+
21
+ it "should not render new" do
22
+ begin
23
+ get :new
24
+
25
+ assert false
26
+ rescue CanCan::AccessDenied
27
+ assert true
28
+ end
29
+ end
30
+
31
+ context "faking a new group" do
32
+ before do
33
+ model_attributes[:_founder] = Factory(:user).slug
34
+ end
35
+
36
+ it_should_behave_like "Deny Creating"
37
+ end
38
+
39
+ context "an existing group" do
40
+ before do
41
+ @current_model = Factory(:group)
42
+ end
43
+
44
+ it_should_behave_like "Deny Updating"
45
+ it_should_behave_like "Deny Destroying"
46
+ end
18
47
  end
19
48
 
20
49
  describe "when authenticated" do
@@ -43,13 +72,54 @@ describe GroupsController do
43
72
  assert_response :success
44
73
  end
45
74
 
46
- it "should update contact group" do
47
- @group = Factory(:member, :receiver => @user.actor).sender_subject
48
- put :update, :id => @group.to_param,
49
- "group" => { "profile_attributes" => { "organization" => "Social Stream" } }
75
+ it "should render new" do
76
+ get :new, 'group' => { '_founder' => @user.to_param }
77
+
78
+ assert_response :success
79
+ end
50
80
 
51
- response.should redirect_to(@group)
81
+ context "a new own group" do
82
+ before do
83
+ model_attributes[:_founder] = @user.slug
84
+ end
85
+
86
+ it_should_behave_like "Allow Creating"
87
+ end
88
+
89
+ context "a new fake group" do
90
+ before do
91
+ model_attributes[:_founder] = Factory(:user).slug
92
+ end
93
+
94
+ it_should_behave_like "Deny Creating"
95
+ end
96
+
97
+ context "a external group" do
98
+ before do
99
+ @current_model = Factory(:group)
100
+ end
101
+
102
+ it_should_behave_like "Deny Updating"
103
+ it_should_behave_like "Deny Destroying"
52
104
  end
105
+
106
+
107
+ context "a existing own group" do
108
+ before do
109
+ @current_model = Factory(:member, :receiver => @user.actor).sender_subject
110
+ end
111
+
112
+ it "should update contact group" do
113
+ put :update, :id => @current_model.to_param,
114
+ "group" => { "profile_attributes" => { "organization" => "Social Stream" } }
115
+
116
+ response.should redirect_to(@current_model)
117
+ end
118
+
119
+ # it_should_behave_like "Allow Updating"
120
+ it_should_behave_like "Allow Destroying"
121
+ end
122
+
53
123
  end
54
124
  end
55
125
 
@@ -0,0 +1,4 @@
1
+ Factory.define :comment do |p|
2
+ p.sequence(:text) { |n| "Comment #{ n }" }
3
+ p._activity_tie_id { |q| q.association(:friend) }
4
+ end
@@ -1,22 +1,32 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe Tie do
4
- it "should create from relation name" do
5
- relation = Relation.first
6
- sender = Factory(relation.sender_type.underscore)
7
-
8
- receiver_type = relation.receiver_type.present? ?
9
- relation.receiver_type :
10
- relation.sender_type
11
-
12
- receiver = Factory(receiver_type.underscore)
13
-
14
- tie = Factory(:tie, :sender_id => sender.actor.id,
15
- :receiver_id => receiver.actor.id,
16
- :relation_name => relation.name)
17
- tie.should be_valid
18
- end
4
+ context "between 2 users" do
5
+ before do
6
+ @sender, @receiver = 2.times.map{ Factory(:user) }
7
+ end
8
+
9
+ it "should be created from relation name" do
10
+ relation = @sender.relations.first
11
+
12
+ tie = Tie.create(:sender_id => @sender.actor_id,
13
+ :receiver_id => @receiver.actor_id,
14
+ :relation_name => relation.name)
19
15
 
16
+ tie.should_not be_new_record
17
+ end
18
+
19
+ it "should be created from relation_name and permissions" do
20
+ tie = Tie.create :sender_id => @sender.actor_id,
21
+ :receiver_id => @receiver.actor_id,
22
+ :relation_name => "new relation",
23
+ :relation_permissions => [ Permission.first.id, Permission.last.id ]
24
+
25
+ puts tie.errors
26
+ tie.should_not be_new_record
27
+ tie.relation.should_not be_new_record
28
+ end
29
+ end
20
30
 
21
31
  describe "friend" do
22
32
  before do
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: 11
4
+ hash: 9
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 2
10
- version: 0.4.2
9
+ - 3
10
+ version: 0.4.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - GING - DIT - UPM
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-03-31 00:00:00 +02:00
19
+ date: 2011-04-06 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -269,12 +269,12 @@ dependencies:
269
269
  requirements:
270
270
  - - ~>
271
271
  - !ruby/object:Gem::Version
272
- hash: 13
272
+ hash: 11
273
273
  segments:
274
274
  - 3
275
275
  - 0
276
- - 5
277
- version: 3.0.5
276
+ - 6
277
+ version: 3.0.6
278
278
  type: :development
279
279
  version_requirements: *id016
280
280
  - !ruby/object:Gem::Dependency
@@ -434,7 +434,6 @@ files:
434
434
  - app/controllers/omniauth_callbacks_controller.rb
435
435
  - app/controllers/posts_controller.rb
436
436
  - app/controllers/profiles_controller.rb
437
- - app/controllers/pshb_controller.rb
438
437
  - app/controllers/representations_controller.rb
439
438
  - app/controllers/subjects_controller.rb
440
439
  - app/controllers/ties_controller.rb
@@ -560,14 +559,15 @@ files:
560
559
  - app/views/subjects/_toolbar_profile_menu.html.erb
561
560
  - app/views/subjects/_toolbar_profile_menu_basic_options.html.erb
562
561
  - app/views/subjects/_toolbar_profile_menu_tie_options.html.erb
562
+ - app/views/ties/_edit.html.erb
563
563
  - app/views/ties/_form.html.erb
564
564
  - app/views/ties/_new.html.erb
565
565
  - app/views/ties/_pendings.html.erb
566
566
  - app/views/ties/_suggestions.html.erb
567
567
  - app/views/ties/_tie.html.erb
568
568
  - app/views/ties/create.js.erb
569
+ - app/views/ties/edit.html.erb
569
570
  - app/views/ties/new.html.erb
570
- - app/views/ties/new.js.erb
571
571
  - app/views/ties/suggestion.html.erb
572
572
  - app/views/ties/suggestion.js.erb
573
573
  - app/views/users/_groups.html.erb
@@ -593,6 +593,7 @@ files:
593
593
  - lib/generators/social_stream/templates/public/images/boxy/boxy-sw.png
594
594
  - lib/generators/social_stream/templates/public/images/btn/1-facebook.png
595
595
  - lib/generators/social_stream/templates/public/images/btn/_notes/btn_certificates.png.mno
596
+ - lib/generators/social_stream/templates/public/images/btn/arrowBlue.png
596
597
  - lib/generators/social_stream/templates/public/images/btn/arrows-ffffff.png
597
598
  - lib/generators/social_stream/templates/public/images/btn/bold.png
598
599
  - lib/generators/social_stream/templates/public/images/btn/btn_activities.png
@@ -665,6 +666,7 @@ files:
665
666
  - lib/generators/social_stream/templates/public/images/btn/point_blue.png
666
667
  - lib/generators/social_stream/templates/public/images/btn/point_gray.png
667
668
  - lib/generators/social_stream/templates/public/images/btn/search.png
669
+ - lib/generators/social_stream/templates/public/images/btn/shadow.png
668
670
  - lib/generators/social_stream/templates/public/images/btn/share.png
669
671
  - lib/generators/social_stream/templates/public/images/btn/subtime.png
670
672
  - lib/generators/social_stream/templates/public/images/btn/tag_cloud.png
@@ -706,7 +708,9 @@ files:
706
708
  - lib/generators/social_stream/templates/public/images/title_background.png
707
709
  - lib/generators/social_stream/templates/public/images/w3c_css.png
708
710
  - lib/generators/social_stream/templates/public/images/w3c_xhtml.png
711
+ - lib/generators/social_stream/templates/public/javascripts/addContact.js
709
712
  - lib/generators/social_stream/templates/public/javascripts/ajax.paginate.js
713
+ - lib/generators/social_stream/templates/public/javascripts/avatars.js
710
714
  - lib/generators/social_stream/templates/public/javascripts/ckeditor/.htaccess
711
715
  - lib/generators/social_stream/templates/public/javascripts/ckeditor/adapters/jquery.js
712
716
  - lib/generators/social_stream/templates/public/javascripts/ckeditor/ckeditor.js
@@ -917,6 +921,7 @@ files:
917
921
  - lib/generators/social_stream/templates/public/javascripts/ckeditor/skins/v2/skin.js
918
922
  - lib/generators/social_stream/templates/public/javascripts/ckeditor/skins/v2/templates.css
919
923
  - lib/generators/social_stream/templates/public/javascripts/ckeditor/themes/default/theme.js
924
+ - lib/generators/social_stream/templates/public/javascripts/hoverIntent.js
920
925
  - lib/generators/social_stream/templates/public/javascripts/jqcloud-0.1.3.min.js
921
926
  - lib/generators/social_stream/templates/public/javascripts/jquery-ui-1.8.4.custom.min.js
922
927
  - lib/generators/social_stream/templates/public/javascripts/jquery-ui-personalized-1.5.2.packed.js
@@ -937,6 +942,8 @@ files:
937
942
  - lib/generators/social_stream/templates/public/javascripts/superfish.js
938
943
  - lib/generators/social_stream/templates/public/javascripts/ui.dropdownchecklist.js
939
944
  - lib/generators/social_stream/templates/public/stylesheets/default/activities.css
945
+ - lib/generators/social_stream/templates/public/stylesheets/default/addContact.css
946
+ - lib/generators/social_stream/templates/public/stylesheets/default/avatars.css
940
947
  - lib/generators/social_stream/templates/public/stylesheets/default/base.css
941
948
  - lib/generators/social_stream/templates/public/stylesheets/default/carousel.css
942
949
  - lib/generators/social_stream/templates/public/stylesheets/default/fcbkComplete.css
@@ -988,12 +995,12 @@ files:
988
995
  - lib/social_stream/models/supertype.rb
989
996
  - lib/social_stream/populate.rb
990
997
  - lib/social_stream/rails.rb
991
- - lib/social_stream/relations.rb
992
998
  - lib/social_stream/test_helpers.rb
993
999
  - lib/social_stream/test_helpers/controllers.rb
994
1000
  - lib/social_stream/version.rb
995
1001
  - lib/tasks/db/populate.rake
996
1002
  - social_stream.gemspec
1003
+ - spec/controllers/comments_controller_spec.rb
997
1004
  - spec/controllers/contacts_controller_spec.rb
998
1005
  - spec/controllers/frontpage_controller_spec.rb
999
1006
  - spec/controllers/groups_controller_spec.rb
@@ -1037,6 +1044,7 @@ files:
1037
1044
  - spec/dummy/script/rails
1038
1045
  - spec/factories/activity.rb
1039
1046
  - spec/factories/actor.rb
1047
+ - spec/factories/comment.rb
1040
1048
  - spec/factories/group.rb
1041
1049
  - spec/factories/post.rb
1042
1050
  - spec/factories/tie.rb