social_stream 2.1.1 → 2.2.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.
Files changed (188) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -2
  3. data/LICENSE +1 -1
  4. data/base/Rakefile +3 -17
  5. data/base/app/assets/images/flags/de.png +0 -0
  6. data/base/app/assets/images/flags/fr.png +0 -0
  7. data/base/app/assets/images/flags/hu.png +0 -0
  8. data/base/app/assets/images/flags/nl.png +0 -0
  9. data/base/app/assets/javascripts/social_stream/actor.js +34 -0
  10. data/base/app/assets/javascripts/social_stream/contact.js +40 -5
  11. data/base/app/assets/javascripts/social_stream/flash.js +6 -1
  12. data/base/app/assets/javascripts/social_stream/group.js +6 -5
  13. data/base/app/assets/javascripts/social_stream/relation_customs.js +0 -1
  14. data/base/app/assets/stylesheets/social_stream/base/adjust/layout/_adjust.css.sass +3 -0
  15. data/base/app/assets/stylesheets/social_stream/base/buttons/_buttons.scss.sass +0 -2
  16. data/base/app/assets/stylesheets/social_stream/base/contacts/_contacts.css.sass +1 -11
  17. data/base/app/assets/stylesheets/social_stream/base/contacts/layouts/_contacts.css.sass +1 -29
  18. data/base/app/assets/stylesheets/social_stream/base/layouts/_header.css.sass +0 -1
  19. data/base/app/assets/stylesheets/social_stream/base/mixins/_buttons.css.sass +5 -0
  20. data/base/app/assets/stylesheets/social_stream/base/mixins/_layout.css.sass +36 -7
  21. data/base/app/controllers/actors_controller.rb +25 -0
  22. data/base/app/controllers/contacts_controller.rb +38 -8
  23. data/base/app/controllers/groups_controller.rb +2 -21
  24. data/base/app/controllers/profiles_controller.rb +4 -0
  25. data/base/app/controllers/settings_controller.rb +12 -2
  26. data/base/app/controllers/users_controller.rb +0 -8
  27. data/base/app/helpers/contacts_helper.rb +8 -0
  28. data/base/app/models/activity.rb +19 -6
  29. data/base/app/models/actor.rb +49 -11
  30. data/base/app/models/contact.rb +12 -5
  31. data/base/app/models/group.rb +13 -11
  32. data/base/app/models/permission.rb +30 -0
  33. data/base/app/models/relation.rb +17 -7
  34. data/base/app/models/relation/custom.rb +2 -40
  35. data/base/app/models/relation/follow.rb +8 -2
  36. data/base/app/models/relation/owner.rb +10 -0
  37. data/base/app/models/relation/single.rb +7 -4
  38. data/base/app/models/site.rb +1 -1
  39. data/base/app/models/tie.rb +8 -4
  40. data/base/app/views/contacts/_add_button.html.erb +9 -0
  41. data/base/app/views/contacts/_button.html.erb +3 -3
  42. data/base/app/views/contacts/_button_multiple.html.erb +4 -0
  43. data/base/app/views/contacts/_button_simple.html.erb +17 -0
  44. data/base/app/views/contacts/_new_modal.html.erb +22 -0
  45. data/base/app/views/contacts/destroy.js.erb +5 -4
  46. data/base/app/views/contacts/update.js.erb +5 -4
  47. data/base/app/views/devise/confirmations/new.html.erb +14 -9
  48. data/base/app/views/frontpage/_presentation.html.erb +2 -2
  49. data/base/app/views/groups/_form.html.erb +20 -20
  50. data/base/app/views/groups/show.html.erb +5 -5
  51. data/base/app/views/layouts/_header_dropdown_menu.html.erb +3 -5
  52. data/base/app/views/layouts/_header_signed_in.erb +3 -3
  53. data/base/app/views/layouts/_logo_in.html.erb +1 -1
  54. data/base/app/views/layouts/application.html.erb +2 -0
  55. data/base/app/views/permissions/_list.html.erb +1 -1
  56. data/base/app/views/profiles/_avatar.html.erb +1 -5
  57. data/base/app/views/profiles/_avatar_edit.html.erb +5 -0
  58. data/base/app/views/profiles/_comunication-info.html.erb +2 -36
  59. data/base/app/views/profiles/_comunication-info_edit.html.erb +27 -0
  60. data/base/app/views/profiles/_edit_icon.html.erb +0 -1
  61. data/base/app/views/profiles/_experience.html.erb +1 -6
  62. data/base/app/views/profiles/_experience_edit.html.erb +5 -0
  63. data/base/app/views/profiles/_personal.html.erb +1 -39
  64. data/base/app/views/profiles/_personal_edit.html.erb +31 -0
  65. data/base/app/views/profiles/_profile_edit.html.erb +7 -0
  66. data/base/app/views/profiles/_tags.html.erb +1 -4
  67. data/base/app/views/profiles/_tags_edit.html.erb +4 -0
  68. data/base/app/views/profiles/edit.html.erb +24 -0
  69. data/base/app/views/settings/_notifications.html.erb +12 -4
  70. data/base/app/views/users/show.html.erb +5 -5
  71. data/base/config/locales/de.yml +654 -0
  72. data/base/config/locales/en.yml +20 -9
  73. data/base/config/locales/es.yml +151 -140
  74. data/base/config/locales/fr.yml +656 -0
  75. data/base/config/locales/hu.yml +653 -0
  76. data/base/config/locales/nl.yml +656 -0
  77. data/base/config/locales/pt.yml +250 -239
  78. data/base/config/locales/rails.de.yml +203 -0
  79. data/base/config/locales/rails.fr.yml +222 -0
  80. data/base/config/locales/rails.hu.yml +199 -0
  81. data/base/config/locales/rails.nl.yml +199 -0
  82. data/base/config/locales/zh.yml +214 -202
  83. data/base/config/routes.rb +22 -30
  84. data/base/db/migrate/20130708152633_set_group_owners.rb +19 -0
  85. data/base/db/migrate/20130723133530_actor_notification_settings.rb +10 -0
  86. data/base/lib/generators/social_stream/base/templates/initializer.rb +13 -7
  87. data/base/lib/rails/social_stream.rb +2 -0
  88. data/base/lib/social_stream/base.rb +27 -7
  89. data/base/lib/social_stream/base/ability.rb +3 -5
  90. data/base/lib/social_stream/base/autoload.rb +1 -0
  91. data/base/lib/social_stream/base/version.rb +1 -1
  92. data/base/lib/social_stream/controllers/authorship.rb +18 -0
  93. data/base/lib/social_stream/controllers/helpers.rb +18 -4
  94. data/base/lib/social_stream/controllers/objects.rb +2 -8
  95. data/base/lib/social_stream/controllers/subjects.rb +9 -2
  96. data/base/lib/social_stream/models/supertype.rb +2 -0
  97. data/base/lib/social_stream/population/activity_object.rb +6 -8
  98. data/base/lib/social_stream/routing/mapper.rb +52 -0
  99. data/base/social_stream-base.gemspec +4 -7
  100. data/base/spec/controllers/groups_controller_spec.rb +19 -8
  101. data/base/spec/controllers/posts_controller_spec.rb +114 -147
  102. data/base/spec/models/post_authorization_spec.rb +190 -204
  103. data/base/spec/models/post_spec.rb +17 -63
  104. data/base/vendor/assets/javascripts/bootstrap-multiselect.js +434 -127
  105. data/documents/Rakefile +1 -6
  106. data/documents/config/locales/de.yml +93 -0
  107. data/documents/config/locales/es.yml +2 -2
  108. data/documents/config/locales/fr.yml +93 -0
  109. data/documents/config/locales/hu.yml +93 -0
  110. data/documents/config/locales/nl.yml +93 -0
  111. data/documents/config/locales/zh.yml +4 -4
  112. data/documents/config/routes.rb +7 -9
  113. data/documents/lib/social_stream/documents/version.rb +1 -1
  114. data/documents/social_stream-documents.gemspec +4 -4
  115. data/events/Rakefile +1 -6
  116. data/events/config/locales/es.yml +3 -3
  117. data/events/config/locales/zh.yml +3 -3
  118. data/events/lib/social_stream/events/models/actor.rb +2 -1
  119. data/events/lib/social_stream/events/version.rb +1 -1
  120. data/events/social_stream-events.gemspec +1 -1
  121. data/lib/generators/social_stream/install_generator.rb +1 -0
  122. data/lib/social_stream.rb +1 -0
  123. data/lib/social_stream/version.rb +1 -1
  124. data/lib/tasks/i18n.rake +22 -2
  125. data/linkser/Rakefile +1 -6
  126. data/linkser/config/locales/de.yml +17 -0
  127. data/linkser/config/locales/es.yml +2 -2
  128. data/linkser/config/locales/fr.yml +17 -0
  129. data/linkser/config/locales/hu.yml +17 -0
  130. data/linkser/config/locales/nl.yml +17 -0
  131. data/linkser/config/locales/zh.yml +2 -2
  132. data/linkser/lib/social_stream/linkser/version.rb +1 -1
  133. data/linkser/social_stream-linkser.gemspec +1 -1
  134. data/oauth2_server/Rakefile +1 -6
  135. data/oauth2_server/app/assets/images/step_1.png +0 -0
  136. data/oauth2_server/app/assets/images/step_2.png +0 -0
  137. data/oauth2_server/app/assets/images/step_3.png +0 -0
  138. data/oauth2_server/app/assets/javascripts/social_stream/site_client.js +27 -0
  139. data/oauth2_server/app/assets/stylesheets/social_stream/oauth2_server/applications/layout/_applications-oauth2server.css.sass +0 -5
  140. data/oauth2_server/app/assets/stylesheets/social_stream/oauth2_server/create/layout/_create-oauth2server.css.sass +3 -5
  141. data/oauth2_server/app/assets/stylesheets/social_stream/oauth2_server/show/layout/_show-oauth2server.css.sass +8 -6
  142. data/oauth2_server/app/controllers/site/clients_controller.rb +17 -41
  143. data/oauth2_server/app/decorators/social_stream/base/relation_decorator.rb +2 -0
  144. data/oauth2_server/app/decorators/social_stream/base/user_decorator.rb +1 -20
  145. data/oauth2_server/app/models/relation/manager.rb +1 -10
  146. data/oauth2_server/app/models/site/client.rb +4 -2
  147. data/oauth2_server/app/views/site/clients/_destroy.html.erb +11 -0
  148. data/oauth2_server/app/views/site/clients/_edit.html.erb +9 -2
  149. data/oauth2_server/app/views/site/clients/_edit_step_2.html.erb +6 -6
  150. data/oauth2_server/app/views/site/clients/_edit_step_3.html.erb +8 -6
  151. data/oauth2_server/app/views/site/clients/_form.html.erb +11 -11
  152. data/oauth2_server/app/views/site/clients/_list.html.erb +23 -11
  153. data/oauth2_server/app/views/site/clients/edit.html.erb +1 -1
  154. data/oauth2_server/app/views/site/clients/index.html.erb +9 -40
  155. data/oauth2_server/app/views/site/clients/show.html.erb +66 -68
  156. data/oauth2_server/config/locales/en.yml +19 -0
  157. data/oauth2_server/config/locales/es.yml +23 -4
  158. data/oauth2_server/config/locales/zh.yml +32 -13
  159. data/oauth2_server/config/routes.rb +3 -1
  160. data/oauth2_server/lib/social_stream/oauth2_server.rb +4 -1
  161. data/oauth2_server/lib/social_stream/oauth2_server/ability.rb +1 -1
  162. data/oauth2_server/lib/social_stream/oauth2_server/models/user.rb +18 -0
  163. data/oauth2_server/lib/social_stream/oauth2_server/version.rb +1 -1
  164. data/oauth2_server/social_stream-oauth2_server.gemspec +1 -1
  165. data/oauth2_server/spec/controllers/site_clients_controller_authorization_spec.rb +7 -0
  166. data/ostatus/Rakefile +1 -6
  167. data/ostatus/config/locales/zh.yml +8 -8
  168. data/ostatus/lib/social_stream-ostatus.rb +3 -0
  169. data/ostatus/lib/social_stream/ostatus/version.rb +1 -1
  170. data/ostatus/social_stream-ostatus.gemspec +1 -1
  171. data/places/config/locales/es.yml +51 -51
  172. data/presence/config/locales/es.yml +48 -48
  173. data/presence/config/locales/zh.yml +48 -48
  174. data/presence/lib/social_stream/presence/version.rb +1 -1
  175. data/presence/social_stream-presence.gemspec +1 -1
  176. data/social_stream.gemspec +8 -7
  177. metadata +60 -29
  178. data/base/app/assets/javascripts/social_stream/follow.js +0 -28
  179. data/base/app/controllers/followers_controller.rb +0 -34
  180. data/base/app/helpers/followers_helper.rb +0 -5
  181. data/base/app/views/contacts/_link_follow.html.erb +0 -16
  182. data/base/app/views/followers/destroy.js.erb +0 -1
  183. data/base/app/views/followers/index.html.erb +0 -30
  184. data/base/app/views/followers/update.js.erb +0 -3
  185. data/base/app/views/frontpage/_characteristics.html.erb +0 -23
  186. data/base/lib/social_stream/routing/constraints/custom.rb +0 -11
  187. data/base/lib/social_stream/routing/constraints/follow.rb +0 -11
  188. data/base/spec/controllers/followers_controller_spec.rb +0 -37
@@ -47,7 +47,7 @@ Gem::Specification.new do |s|
47
47
  s.add_runtime_dependency('omniauth-facebook','~> 1.4.1')
48
48
  s.add_runtime_dependency('omniauth-linkedin','~> 0.0.6')
49
49
  # Messages
50
- s.add_runtime_dependency('mailboxer','~> 0.10.2')
50
+ s.add_runtime_dependency('mailboxer','~> 0.10.3')
51
51
  # Tagging
52
52
  s.add_runtime_dependency('acts-as-taggable-on','~> 2.2.2')
53
53
  # Background jobs
@@ -77,12 +77,6 @@ Gem::Specification.new do |s|
77
77
  s.add_development_dependency('capybara', '~> 0.3.9')
78
78
  # Testing database
79
79
  s.add_development_dependency('sqlite3-ruby')
80
- # Debugging
81
- if RUBY_VERSION < '1.9'
82
- s.add_development_dependency('ruby-debug')
83
- else
84
- s.add_development_dependency('debugger')
85
- end
86
80
  # Specs
87
81
  s.add_development_dependency('rspec-rails', '~> 2.6.1')
88
82
  # Fixtures
@@ -93,4 +87,7 @@ Gem::Specification.new do |s|
93
87
  s.add_development_dependency('ci_reporter', '~> 1.6.4')
94
88
  # Scaffold generator
95
89
  s.add_development_dependency('nifty-generators','~> 0.4.5')
90
+ # pry
91
+ s.add_development_dependency('pry-rails','~> 0.4.5')
92
+
96
93
  end
@@ -78,17 +78,17 @@ describe GroupsController do
78
78
  @user.senders.should include(group.actor)
79
79
  end
80
80
 
81
- context "with participants" do
81
+ context "with owners" do
82
82
  before do
83
- @user_participant = Factory(:user)
84
- @group_participant = Factory(:group)
83
+ @user_owner = Factory(:user)
84
+ @group_owner = Factory(:group)
85
85
  end
86
86
 
87
87
  it "should allow creating" do
88
88
  count = Group.count
89
89
  post :create,
90
90
  :group => { :name => "Test group",
91
- :_participants => [ @user_participant.actor_id, @group_participant.actor_id ].join(',') }
91
+ :owners => [ @user_owner.actor_id, @group_owner.actor_id ].join(',') }
92
92
 
93
93
  group = assigns(:group)
94
94
 
@@ -96,10 +96,10 @@ describe GroupsController do
96
96
  Group.count.should eq(count + 1)
97
97
  assigns(:current_subject).should eq(group)
98
98
 
99
- participants = group.contact_subjects(:direction => :sent)
99
+ owners = group.contact_subjects(:direction => :sent)
100
100
 
101
- participants.should include(@user_participant)
102
- participants.should include(@group_participant)
101
+ owners.should include(@user_owner)
102
+ owners.should include(@group_owner)
103
103
 
104
104
  group.contact_subjects(:direction => :received)
105
105
  response.should redirect_to(:home)
@@ -115,7 +115,18 @@ describe GroupsController do
115
115
  model_attributes[:user_author_id] = user.actor_id
116
116
  end
117
117
 
118
- it_should_behave_like "Deny Creating"
118
+ it "should create but own" do
119
+ count = model_count
120
+ post :create, attributes
121
+
122
+ resource = assigns(demodulized_model_sym)
123
+
124
+ model_count.should eq(count + 1)
125
+ resource.should be_valid
126
+ resource.author.should eq(@user.actor)
127
+ resource.user_author.should eq(@user.actor)
128
+ response.should redirect_to(:home)
129
+ end
119
130
  end
120
131
 
121
132
  context "a external group" do
@@ -7,144 +7,133 @@ describe PostsController do
7
7
  render_views
8
8
 
9
9
  describe "authorizing" do
10
- before :all do
11
- @ss_relation_model = SocialStream.relation_model
10
+ before do
11
+ @user = Factory(:user)
12
+ sign_in @user
12
13
  end
13
14
 
14
- after :all do
15
- SocialStream.relation_model = @ss_relation_model
16
- end
17
-
18
- describe "in follow relation model" do
19
- before :all do
20
- SocialStream.relation_model = :follow
21
- end
22
-
23
- before do
24
- @user = Factory(:user)
25
- sign_in @user
26
- end
27
-
28
- describe "post from other user" do
15
+ describe "posts to user" do
16
+ describe "with first relation" do
29
17
  before do
30
- @current_model = Factory(:post)
18
+ contact = @user.contact_to!(@user)
19
+ relation = @user.relation_customs.sort.first
20
+ model_assigned_to @user.contact_to!(@user), relation
21
+ @current_model = Factory(:post, :author_id => @user.actor_id,
22
+ :owner_id => @user.actor_id,
23
+ :user_author_id => @user.actor_id,
24
+ :relation_ids => Array(relation.id))
31
25
  end
32
26
 
27
+ it_should_behave_like "Allow Creating"
33
28
  it_should_behave_like "Allow Reading"
34
- end
35
- end
29
+ it_should_behave_like "Allow Destroying"
36
30
 
37
- describe "in custom relation mode" do
38
- before :all do
39
- SocialStream.relation_model = :custom
40
- end
31
+ it "should destroy with js" do
32
+ count = model_count
33
+ delete :destroy, :id => @current_model.to_param, :format => :js
41
34
 
42
- before do
43
- @user = Factory(:user)
44
- sign_in @user
45
- end
46
-
47
- describe "posts to user" do
48
- describe "with first relation" do
49
- before do
50
- contact = @user.contact_to!(@user)
51
- relation = @user.relation_customs.sort.first
52
- model_assigned_to @user.contact_to!(@user), relation
53
- @current_model = Factory(:post, :author_id => @user.actor_id,
54
- :owner_id => @user.actor_id,
55
- :user_author_id => @user.actor_id,
56
- :relation_ids => Array(relation.id))
57
- end
58
-
59
- it_should_behave_like "Allow Creating"
60
- it_should_behave_like "Allow Reading"
61
- it_should_behave_like "Allow Destroying"
35
+ resource = assigns(model_sym)
62
36
 
63
- it "should destroy with js" do
64
- count = model_count
65
- delete :destroy, :id => @current_model.to_param, :format => :js
66
-
67
- resource = assigns(model_sym)
68
-
69
- model_count.should eq(count - 1)
70
- end
37
+ model_count.should eq(count - 1)
71
38
  end
39
+ end
72
40
 
73
- describe "with last relation" do
74
- before do
75
- contact = @user.contact_to!(@user)
76
- relation = @user.relation_customs.sort.last
77
- model_assigned_to @user.contact_to!(@user), relation
78
- @current_model = Factory(:post, :author_id => @user.actor_id,
79
- :owner_id => @user.actor_id,
80
- :user_author_id => @user.actor_id,
81
- :relation_ids => Array(relation.id))
82
- end
83
-
84
- it_should_behave_like "Allow Creating"
85
- it_should_behave_like "Allow Reading"
86
- it_should_behave_like "Allow Destroying"
41
+ describe "with last relation" do
42
+ before do
43
+ contact = @user.contact_to!(@user)
44
+ relation = @user.relation_customs.sort.last
45
+ model_assigned_to @user.contact_to!(@user), relation
46
+ @current_model = Factory(:post, :author_id => @user.actor_id,
47
+ :owner_id => @user.actor_id,
48
+ :user_author_id => @user.actor_id,
49
+ :relation_ids => Array(relation.id))
87
50
  end
88
51
 
89
- describe "with public relation" do
90
- before do
91
- contact = @user.contact_to!(@user)
92
- relation = Relation::Public.instance
93
- model_assigned_to @user.contact_to!(@user), relation
94
- @current_model = Factory(:post, :author_id => @user.actor_id,
95
- :owner_id => @user.actor_id,
96
- :user_author_id => @user.actor_id)
97
- end
98
-
99
- it_should_behave_like "Allow Creating"
100
- it_should_behave_like "Allow Reading"
101
- it_should_behave_like "Allow Destroying"
102
- end
52
+ it_should_behave_like "Allow Creating"
53
+ it_should_behave_like "Allow Reading"
54
+ it_should_behave_like "Allow Destroying"
103
55
  end
104
56
 
105
- describe "post to friend" do
57
+ describe "with public relation" do
106
58
  before do
107
- friend = Factory(:friend, :contact => Factory(:contact, :receiver => @user.actor)).sender
108
-
109
- model_assigned_to @user.contact_to!(friend), friend.relation_custom('friend')
59
+ contact = @user.contact_to!(@user)
60
+ relation = Relation::Public.instance
61
+ model_assigned_to @user.contact_to!(@user), relation
110
62
  @current_model = Factory(:post, :author_id => @user.actor_id,
111
- :owner_id => friend.id,
63
+ :owner_id => @user.actor_id,
112
64
  :user_author_id => @user.actor_id)
113
65
  end
114
66
 
115
67
  it_should_behave_like "Allow Creating"
116
68
  it_should_behave_like "Allow Reading"
69
+ it_should_behave_like "Allow Destroying"
117
70
  end
71
+ end
118
72
 
119
- describe "post to acquaintance" do
120
- before do
121
- ac = Factory(:acquaintance, :contact => Factory(:contact, :receiver => @user.actor)).sender
73
+ describe "post to friend" do
74
+ before do
75
+ friend = Factory(:friend, :contact => Factory(:contact, :receiver => @user.actor)).sender
122
76
 
123
- model_assigned_to @user.contact_to!(ac), ac.relation_custom('acquaintance')
124
- end
77
+ model_assigned_to @user.contact_to!(friend), friend.relation_custom('friend')
78
+ @current_model = Factory(:post, :author_id => @user.actor_id,
79
+ :owner_id => friend.id,
80
+ :user_author_id => @user.actor_id)
81
+ end
125
82
 
126
- it_should_behave_like "Deny Creating"
83
+ it_should_behave_like "Allow Creating"
84
+ it_should_behave_like "Allow Reading"
85
+ end
86
+
87
+ describe "post to acquaintance" do
88
+ before do
89
+ ac = Factory(:acquaintance, :contact => Factory(:contact, :receiver => @user.actor)).sender
90
+
91
+ model_assigned_to @user.contact_to!(ac), ac.relation_custom('acquaintance')
127
92
  end
128
93
 
129
- describe "post from other user" do
94
+ it_should_behave_like "Deny Creating"
95
+ end
96
+
97
+ describe "post from other user" do
98
+ before do
99
+ @current_model = Factory(:post)
100
+ end
101
+
102
+
103
+ it_should_behave_like "Deny Reading"
104
+ end
105
+
106
+ describe "posts represented group" do
107
+ before do
108
+ @group = Factory(:member, :contact => Factory(:group_contact, :receiver => @user.actor)).sender_subject
109
+ end
110
+
111
+ describe "with member relation" do
130
112
  before do
131
- @current_model = Factory(:post)
113
+ contact = @user.contact_to!(@group)
114
+ relation = @group.relation_custom('member')
115
+
116
+ model_assigned_to contact, relation
117
+ @current_model = Factory(:post, :author_id => contact.sender.id,
118
+ :owner_id => contact.receiver.id,
119
+ :user_author_id => contact.sender.id,
120
+ :relation_ids => Array(relation.id))
132
121
  end
133
122
 
134
-
135
- it_should_behave_like "Deny Reading"
123
+ it_should_behave_like "Allow Creating"
124
+ it_should_behave_like "Allow Reading"
125
+ it_should_behave_like "Allow Destroying"
136
126
  end
137
127
 
138
- describe "posts represented group" do
128
+ context "representing the group" do
139
129
  before do
140
- @group = Factory(:member, :contact => Factory(:group_contact, :receiver => @user.actor)).sender_subject
130
+ represent(@group)
141
131
  end
142
132
 
143
- describe "with member relation" do
133
+ describe "with first relation" do
144
134
  before do
145
- contact = @user.contact_to!(@group)
146
- relation = @group.relation_custom('member')
147
-
135
+ contact = @group.contact_to!(@group)
136
+ relation = @group.relation_customs.sort.first
148
137
  model_assigned_to contact, relation
149
138
  @current_model = Factory(:post, :author_id => contact.sender.id,
150
139
  :owner_id => contact.receiver.id,
@@ -157,58 +146,36 @@ describe PostsController do
157
146
  it_should_behave_like "Allow Destroying"
158
147
  end
159
148
 
160
- context "representing the group" do
149
+ describe "with last relation" do
161
150
  before do
162
- represent(@group)
151
+ contact = @group.contact_to!(@group)
152
+ relation = @group.relation_customs.sort.last
153
+ model_assigned_to contact, relation
154
+ @current_model = Factory(:post, :author_id => contact.sender.id,
155
+ :owner_id => contact.receiver.id,
156
+ :user_author_id => contact.sender.id,
157
+ :relation_ids => Array(relation.id))
163
158
  end
164
159
 
165
- describe "with first relation" do
166
- before do
167
- contact = @group.contact_to!(@group)
168
- relation = @group.relation_customs.sort.first
169
- model_assigned_to contact, relation
170
- @current_model = Factory(:post, :author_id => contact.sender.id,
171
- :owner_id => contact.receiver.id,
172
- :user_author_id => contact.sender.id,
173
- :relation_ids => Array(relation.id))
174
- end
175
-
176
- it_should_behave_like "Allow Creating"
177
- it_should_behave_like "Allow Reading"
178
- it_should_behave_like "Allow Destroying"
179
- end
160
+ it_should_behave_like "Allow Creating"
161
+ it_should_behave_like "Allow Reading"
162
+ it_should_behave_like "Allow Destroying"
163
+ end
180
164
 
181
- describe "with last relation" do
182
- before do
183
- contact = @group.contact_to!(@group)
184
- relation = @group.relation_customs.sort.last
185
- model_assigned_to contact, relation
186
- @current_model = Factory(:post, :author_id => contact.sender.id,
187
- :owner_id => contact.receiver.id,
188
- :user_author_id => contact.sender.id,
189
- :relation_ids => Array(relation.id))
190
- end
191
-
192
- it_should_behave_like "Allow Creating"
193
- it_should_behave_like "Allow Reading"
194
- it_should_behave_like "Allow Destroying"
165
+ describe "with public relation" do
166
+ before do
167
+ contact = @group.contact_to!(@group)
168
+ relation = Relation::Public.instance
169
+ model_assigned_to contact, relation
170
+ @current_model = Factory(:post, :author_id => contact.sender.id,
171
+ :owner_id => contact.receiver.id,
172
+ :user_author_id => contact.sender.id,
173
+ :relation_ids => Array(relation.id))
195
174
  end
196
175
 
197
- describe "with public relation" do
198
- before do
199
- contact = @group.contact_to!(@group)
200
- relation = Relation::Public.instance
201
- model_assigned_to contact, relation
202
- @current_model = Factory(:post, :author_id => contact.sender.id,
203
- :owner_id => contact.receiver.id,
204
- :user_author_id => contact.sender.id,
205
- :relation_ids => Array(relation.id))
206
- end
207
-
208
- it_should_behave_like "Allow Creating"
209
- it_should_behave_like "Allow Reading"
210
- it_should_behave_like "Allow Destroying"
211
- end
176
+ it_should_behave_like "Allow Creating"
177
+ it_should_behave_like "Allow Reading"
178
+ it_should_behave_like "Allow Destroying"
212
179
  end
213
180
  end
214
181
  end
@@ -73,166 +73,243 @@ describe Post do
73
73
  include PostAuthorizationTestHelper
74
74
 
75
75
  before :all do
76
- @ss_relation_model = SocialStream.relation_model
76
+ @subject = @user = Factory(:user)
77
77
  end
78
78
 
79
- after :all do
80
- SocialStream.relation_model = @ss_relation_model
81
- end
82
-
83
- context "in custom relation model" do
84
- before :all do
85
- SocialStream.relation_model = :custom
86
- end
87
-
79
+ context "with friend tie" do
88
80
  before :all do
89
- @subject = @user = Factory(:user)
81
+ @tie = create_related_tie(:friend)
90
82
  end
91
83
 
92
- context "with friend tie" do
84
+ describe "posting for all contacts" do
93
85
  before :all do
94
- @tie = create_related_tie(:friend)
86
+ @post = Factory(:post,
87
+ :author => @tie.receiver,
88
+ :owner => @tie.sender)
95
89
  end
96
90
 
97
- describe "posting for all contacts" do
98
- before :all do
99
- @post = Factory(:post,
100
- :author => @tie.receiver,
101
- :owner => @tie.sender)
91
+ describe "accesed by author" do
92
+ before do
93
+ create_ability_accessed_by(@post.author_subject)
102
94
  end
103
95
 
104
- describe "accesed by author" do
105
- before do
106
- create_ability_accessed_by(@post.author_subject)
107
- end
96
+ it_should_behave_like "Allows Creating"
97
+ it_should_behave_like "Allows Reading"
98
+ it_should_behave_like "Allows Updating"
99
+ it_should_behave_like "Allows Destroying"
100
+ end
108
101
 
109
- it_should_behave_like "Allows Creating"
110
- it_should_behave_like "Allows Reading"
111
- it_should_behave_like "Allows Updating"
112
- it_should_behave_like "Allows Destroying"
102
+ describe "accesed by owner" do
103
+ before do
104
+ create_ability_accessed_by(@post.owner_subject)
113
105
  end
114
106
 
115
- describe "accesed by owner" do
116
- before do
117
- create_ability_accessed_by(@post.owner_subject)
118
- end
107
+ it_should_behave_like "Denies Creating"
108
+ it_should_behave_like "Allows Reading"
109
+ it_should_behave_like "Allows Updating"
110
+ it_should_behave_like "Allows Destroying"
111
+ end
119
112
 
120
- it_should_behave_like "Denies Creating"
121
- it_should_behave_like "Allows Reading"
122
- it_should_behave_like "Allows Updating"
123
- it_should_behave_like "Allows Destroying"
113
+ describe "accessed by different friend" do
114
+ before do
115
+ create_ability_accessed_by_related :friend
124
116
  end
125
117
 
126
- describe "accessed by different friend" do
127
- before do
128
- create_ability_accessed_by_related :friend
129
- end
118
+ it_should_behave_like "Denies Creating"
119
+ it_should_behave_like "Allows Reading"
120
+ it_should_behave_like "Denies Updating"
121
+ it_should_behave_like "Denies Destroying"
122
+ end
130
123
 
131
- it_should_behave_like "Denies Creating"
132
- it_should_behave_like "Allows Reading"
133
- it_should_behave_like "Denies Updating"
134
- it_should_behave_like "Denies Destroying"
124
+ describe "accessed by acquaintance" do
125
+ before do
126
+ create_ability_accessed_by_related :acquaintance
135
127
  end
128
+ it_should_behave_like "Denies Creating"
129
+ it_should_behave_like "Allows Reading"
130
+ it_should_behave_like "Denies Updating"
131
+ it_should_behave_like "Denies Destroying"
132
+ end
136
133
 
137
- describe "accessed by acquaintance" do
138
- before do
139
- create_ability_accessed_by_related :acquaintance
140
- end
141
- it_should_behave_like "Denies Creating"
142
- it_should_behave_like "Allows Reading"
143
- it_should_behave_like "Denies Updating"
144
- it_should_behave_like "Denies Destroying"
134
+ describe "accessed publicly" do
135
+ before do
136
+ create_ability_accessed_publicly
145
137
  end
146
138
 
147
- describe "accessed publicly" do
148
- before do
149
- create_ability_accessed_publicly
150
- end
139
+ it_should_behave_like "Denies Creating"
140
+ it_should_behave_like "Denies Reading"
141
+ it_should_behave_like "Denies Updating"
142
+ it_should_behave_like "Denies Destroying"
143
+ end
144
+ end
151
145
 
152
- it_should_behave_like "Denies Creating"
153
- it_should_behave_like "Denies Reading"
154
- it_should_behave_like "Denies Updating"
155
- it_should_behave_like "Denies Destroying"
146
+ describe "posting only to friends" do
147
+ before :all do
148
+ @post = Factory(:post,
149
+ :author => @tie.receiver,
150
+ :owner => @tie.sender,
151
+ :relation_ids => [@tie.relation_id])
152
+
153
+ end
154
+
155
+ describe "accessed by author" do
156
+ before do
157
+ create_ability_accessed_by(@post.author_subject)
156
158
  end
159
+
160
+ it_should_behave_like "Allows Creating"
161
+ it_should_behave_like "Allows Reading"
162
+ it_should_behave_like "Allows Updating"
163
+ it_should_behave_like "Allows Destroying"
157
164
  end
158
165
 
159
- describe "posting only to friends" do
160
- before :all do
161
- @post = Factory(:post,
162
- :author => @tie.receiver,
163
- :owner => @tie.sender,
164
- :relation_ids => [@tie.relation_id])
166
+ describe "accesed by owner" do
167
+ before do
168
+ create_ability_accessed_by(@post.owner_subject)
169
+ end
170
+
171
+ it_should_behave_like "Denies Creating"
172
+ it_should_behave_like "Allows Reading"
173
+ it_should_behave_like "Allows Updating"
174
+ it_should_behave_like "Allows Destroying"
175
+ end
165
176
 
177
+ describe "accessed by a friend" do
178
+ before do
179
+ create_ability_accessed_by_related :friend
166
180
  end
167
181
 
168
- describe "accessed by author" do
169
- before do
170
- create_ability_accessed_by(@post.author_subject)
171
- end
182
+ it_should_behave_like "Denies Creating"
183
+ it_should_behave_like "Allows Reading"
184
+ it_should_behave_like "Denies Updating"
185
+ it_should_behave_like "Denies Destroying"
186
+ end
172
187
 
173
- it_should_behave_like "Allows Creating"
174
- it_should_behave_like "Allows Reading"
175
- it_should_behave_like "Allows Updating"
176
- it_should_behave_like "Allows Destroying"
188
+ describe "accessed by acquaintance" do
189
+ before do
190
+ create_ability_accessed_by_related :acquaintance
177
191
  end
178
192
 
179
- describe "accesed by owner" do
180
- before do
181
- create_ability_accessed_by(@post.owner_subject)
182
- end
193
+ it_should_behave_like "Denies Creating"
194
+ it_should_behave_like "Denies Reading"
195
+ it_should_behave_like "Denies Updating"
196
+ it_should_behave_like "Denies Destroying"
197
+ end
183
198
 
184
- it_should_behave_like "Denies Creating"
185
- it_should_behave_like "Allows Reading"
186
- it_should_behave_like "Allows Updating"
187
- it_should_behave_like "Allows Destroying"
199
+ describe "accessed publicly" do
200
+ before do
201
+ create_ability_accessed_publicly
188
202
  end
189
203
 
190
- describe "accessed by a friend" do
191
- before do
192
- create_ability_accessed_by_related :friend
193
- end
204
+ it_should_behave_like "Denies Creating"
205
+ it_should_behave_like "Denies Reading"
206
+ it_should_behave_like "Denies Updating"
207
+ it_should_behave_like "Denies Destroying"
208
+ end
209
+ end
194
210
 
195
- it_should_behave_like "Denies Creating"
196
- it_should_behave_like "Allows Reading"
197
- it_should_behave_like "Denies Updating"
198
- it_should_behave_like "Denies Destroying"
211
+ describe "posting to public relation" do
212
+
213
+ before do
214
+ @post = Factory(:post,
215
+ :author => @tie.receiver,
216
+ :owner => @tie.sender,
217
+ :relation_ids => [Relation::Public.instance.id])
218
+ end
219
+
220
+ describe "accessed by author" do
221
+ before do
222
+ create_ability_accessed_by(@post.author_subject)
199
223
  end
200
224
 
201
- describe "accessed by acquaintance" do
202
- before do
203
- create_ability_accessed_by_related :acquaintance
204
- end
225
+ it_should_behave_like "Allows Creating"
226
+ it_should_behave_like "Allows Reading"
227
+ it_should_behave_like "Allows Updating"
228
+ it_should_behave_like "Allows Destroying"
229
+ end
205
230
 
206
- it_should_behave_like "Denies Creating"
207
- it_should_behave_like "Denies Reading"
208
- it_should_behave_like "Denies Updating"
209
- it_should_behave_like "Denies Destroying"
231
+ describe "accessed by owner" do
232
+ before do
233
+ create_ability_accessed_by(@post.owner_subject)
210
234
  end
211
235
 
212
- describe "accessed publicly" do
213
- before do
214
- create_ability_accessed_publicly
215
- end
236
+ it_should_behave_like "Denies Creating"
237
+ it_should_behave_like "Allows Reading"
238
+ it_should_behave_like "Allows Updating"
239
+ it_should_behave_like "Allows Destroying"
240
+ end
216
241
 
217
- it_should_behave_like "Denies Creating"
218
- it_should_behave_like "Denies Reading"
219
- it_should_behave_like "Denies Updating"
220
- it_should_behave_like "Denies Destroying"
242
+ describe "accessed by a friend" do
243
+ before do
244
+ create_ability_accessed_by_related :friend
245
+ end
246
+
247
+ it_should_behave_like "Denies Creating"
248
+ it_should_behave_like "Allows Reading"
249
+ it_should_behave_like "Denies Updating"
250
+ it_should_behave_like "Denies Destroying"
251
+ end
252
+
253
+ describe "accessed by acquaintance" do
254
+ before do
255
+ create_ability_accessed_by_related :acquaintance
256
+ end
257
+
258
+ it_should_behave_like "Denies Creating"
259
+ it_should_behave_like "Allows Reading"
260
+ it_should_behave_like "Denies Updating"
261
+ it_should_behave_like "Denies Destroying"
262
+ end
263
+
264
+ describe "accessed publicly" do
265
+ before do
266
+ create_ability_accessed_publicly
221
267
  end
268
+
269
+ it_should_behave_like "Denies Creating"
270
+ it_should_behave_like "Allows Reading"
271
+ it_should_behave_like "Denies Updating"
272
+ it_should_behave_like "Denies Destroying"
222
273
  end
274
+ end
223
275
 
224
- describe "posting to public relation" do
276
+ describe "posting by not replied" do
277
+ before :all do
278
+ @post = Factory(:post,
279
+ :author => @tie.sender,
280
+ :owner => @tie.receiver)
281
+ end
225
282
 
283
+ describe "accessed by author" do
226
284
  before do
285
+ create_ability_accessed_by(@post.author_subject)
286
+ end
287
+
288
+ it_should_behave_like "Denies Creating"
289
+ end
290
+ end
291
+ end
292
+
293
+ context "group" do
294
+ before(:all) do
295
+ @subject = @group = Factory(:group)
296
+ end
297
+
298
+ describe "with member tie" do
299
+ before :all do
300
+ @tie = create_related_tie(:member)
301
+ end
302
+
303
+ describe "posting from member all contacts" do
304
+ before :all do
227
305
  @post = Factory(:post,
228
306
  :author => @tie.receiver,
229
- :owner => @tie.sender,
230
- :relation_ids => [Relation::Public.instance.id])
307
+ :owner => @tie.sender)
231
308
  end
232
309
 
233
310
  describe "accessed by author" do
234
311
  before do
235
- create_ability_accessed_by(@post.author_subject)
312
+ create_ability_accessed_by @post.author_subject
236
313
  end
237
314
 
238
315
  it_should_behave_like "Allows Creating"
@@ -241,20 +318,9 @@ describe Post do
241
318
  it_should_behave_like "Allows Destroying"
242
319
  end
243
320
 
244
- describe "accessed by owner" do
245
- before do
246
- create_ability_accessed_by(@post.owner_subject)
247
- end
248
-
249
- it_should_behave_like "Denies Creating"
250
- it_should_behave_like "Allows Reading"
251
- it_should_behave_like "Allows Updating"
252
- it_should_behave_like "Allows Destroying"
253
- end
254
-
255
- describe "accessed by a friend" do
321
+ describe "accessed by different member" do
256
322
  before do
257
- create_ability_accessed_by_related :friend
323
+ create_ability_accessed_by_related :member
258
324
  end
259
325
 
260
326
  it_should_behave_like "Denies Creating"
@@ -263,9 +329,9 @@ describe Post do
263
329
  it_should_behave_like "Denies Destroying"
264
330
  end
265
331
 
266
- describe "accessed by acquaintance" do
332
+ describe "accessed by partner" do
267
333
  before do
268
- create_ability_accessed_by_related :acquaintance
334
+ create_ability_accessed_by_related :partner
269
335
  end
270
336
 
271
337
  it_should_behave_like "Denies Creating"
@@ -280,91 +346,11 @@ describe Post do
280
346
  end
281
347
 
282
348
  it_should_behave_like "Denies Creating"
283
- it_should_behave_like "Allows Reading"
349
+ it_should_behave_like "Denies Reading"
284
350
  it_should_behave_like "Denies Updating"
285
351
  it_should_behave_like "Denies Destroying"
286
352
  end
287
353
  end
288
-
289
- describe "posting by not replied" do
290
- before :all do
291
- @post = Factory(:post,
292
- :author => @tie.sender,
293
- :owner => @tie.receiver)
294
- end
295
-
296
- describe "accessed by author" do
297
- before do
298
- create_ability_accessed_by(@post.author_subject)
299
- end
300
-
301
- it_should_behave_like "Denies Creating"
302
- end
303
- end
304
- end
305
-
306
- context "group" do
307
- before(:all) do
308
- @subject = @group = Factory(:group)
309
- end
310
-
311
- describe "with member tie" do
312
- before :all do
313
- @tie = create_related_tie(:member)
314
- end
315
-
316
- describe "posting from member all contacts" do
317
- before :all do
318
- @post = Factory(:post,
319
- :author => @tie.receiver,
320
- :owner => @tie.sender)
321
- end
322
-
323
- describe "accessed by author" do
324
- before do
325
- create_ability_accessed_by @post.author_subject
326
- end
327
-
328
- it_should_behave_like "Allows Creating"
329
- it_should_behave_like "Allows Reading"
330
- it_should_behave_like "Allows Updating"
331
- it_should_behave_like "Allows Destroying"
332
- end
333
-
334
- describe "accessed by different member" do
335
- before do
336
- create_ability_accessed_by_related :member
337
- end
338
-
339
- it_should_behave_like "Denies Creating"
340
- it_should_behave_like "Allows Reading"
341
- it_should_behave_like "Denies Updating"
342
- it_should_behave_like "Denies Destroying"
343
- end
344
-
345
- describe "accessed by partner" do
346
- before do
347
- create_ability_accessed_by_related :partner
348
- end
349
-
350
- it_should_behave_like "Denies Creating"
351
- it_should_behave_like "Allows Reading"
352
- it_should_behave_like "Denies Updating"
353
- it_should_behave_like "Denies Destroying"
354
- end
355
-
356
- describe "accessed publicly" do
357
- before do
358
- create_ability_accessed_publicly
359
- end
360
-
361
- it_should_behave_like "Denies Creating"
362
- it_should_behave_like "Denies Reading"
363
- it_should_behave_like "Denies Updating"
364
- it_should_behave_like "Denies Destroying"
365
- end
366
- end
367
- end
368
354
  end
369
355
  end
370
356
  end