social_stream-base 0.19.1 → 0.19.2
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/conversations_controller.rb +15 -10
- data/app/controllers/followers_controller.rb +4 -9
- data/app/helpers/permissions_helper.rb +4 -0
- data/app/models/activity_action.rb +4 -0
- data/app/models/activity_object.rb +9 -0
- data/app/models/actor.rb +19 -0
- data/app/models/group.rb +5 -0
- data/app/models/relation/single.rb +2 -1
- data/app/models/user.rb +1 -1
- data/app/views/conversations/destroy.js.erb +2 -0
- data/app/views/followers/index.html.erb +26 -5
- data/app/views/permissions/_index.html.erb +7 -2
- data/app/views/profiles/update.js.erb +4 -9
- data/app/views/relation/customs/_list.html.erb +4 -0
- data/config/locales/en.yml +4 -0
- data/config/locales/es.yml +5 -1
- data/config/routes.rb +31 -32
- data/lib/generators/social_stream/base/templates/initializer.rb +5 -1
- data/lib/social_stream-base.rb +12 -1
- data/lib/social_stream/base/version.rb +1 -1
- data/lib/social_stream/models/object.rb +5 -0
- data/lib/social_stream/models/supertype.rb +1 -1
- data/lib/social_stream/routing/constraints/custom.rb +11 -0
- data/lib/social_stream/routing/constraints/follow.rb +11 -0
- data/lib/social_stream/routing/constraints/resque.rb +11 -0
- data/spec/controllers/followers_controller_spec.rb +37 -0
- data/spec/controllers/posts_controller_spec.rb +196 -163
- data/spec/dummy/config/initializers/social_stream.rb +5 -1
- data/spec/factories/tie.rb +4 -0
- data/spec/integration/resque_access_spec.rb +30 -0
- data/spec/models/post_spec.rb +66 -17
- metadata +70 -64
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FollowersController do
|
4
|
+
include SocialStream::TestHelpers::Controllers
|
5
|
+
|
6
|
+
render_views
|
7
|
+
|
8
|
+
describe "with followers" do
|
9
|
+
before do
|
10
|
+
@user = Factory(:user)
|
11
|
+
|
12
|
+
@follow = Factory(:follow, :contact => Factory(:contact, :sender => @user.actor))
|
13
|
+
|
14
|
+
sign_in @user
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should render index" do
|
18
|
+
get :index
|
19
|
+
|
20
|
+
response.should be_success
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "with post" do
|
24
|
+
before do
|
25
|
+
Factory(:self_post, :author_id => @user.actor_id)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should render index" do
|
29
|
+
get :index
|
30
|
+
|
31
|
+
response.should be_success
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
@@ -7,153 +7,149 @@ describe PostsController do
|
|
7
7
|
render_views
|
8
8
|
|
9
9
|
describe "authorizing" do
|
10
|
-
before do
|
11
|
-
@
|
12
|
-
sign_in @user
|
10
|
+
before :all do
|
11
|
+
@ss_relation_model = SocialStream.relation_model
|
13
12
|
end
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
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))
|
25
|
-
end
|
26
|
-
|
27
|
-
it_should_behave_like "Allow Creating"
|
28
|
-
it_should_behave_like "Allow Reading"
|
29
|
-
it_should_behave_like "Allow Destroying"
|
30
|
-
|
31
|
-
it "should destroy with js" do
|
32
|
-
count = model_count
|
33
|
-
delete :destroy, :id => @current_model.to_param, :format => :js
|
34
|
-
|
35
|
-
resource = assigns(model_sym)
|
14
|
+
after :all do
|
15
|
+
SocialStream.relation_model = @ss_relation_model
|
16
|
+
end
|
36
17
|
|
37
|
-
|
38
|
-
|
18
|
+
describe "in follow relation model" do
|
19
|
+
before :all do
|
20
|
+
SocialStream.relation_model = :follow
|
39
21
|
end
|
40
22
|
|
41
|
-
|
42
|
-
|
43
|
-
|
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))
|
50
|
-
end
|
51
|
-
|
52
|
-
it_should_behave_like "Allow Creating"
|
53
|
-
it_should_behave_like "Allow Reading"
|
54
|
-
it_should_behave_like "Allow Destroying"
|
23
|
+
before do
|
24
|
+
@user = Factory(:user)
|
25
|
+
sign_in @user
|
55
26
|
end
|
56
27
|
|
57
|
-
describe "
|
28
|
+
describe "post from other user" do
|
58
29
|
before do
|
59
|
-
|
60
|
-
relation = Relation::Public.instance
|
61
|
-
model_assigned_to @user.contact_to!(@user), relation
|
62
|
-
@current_model = Factory(:post, :author_id => @user.actor_id,
|
63
|
-
:owner_id => @user.actor_id,
|
64
|
-
:user_author_id => @user.actor_id)
|
30
|
+
@current_model = Factory(:post)
|
65
31
|
end
|
66
32
|
|
67
|
-
it_should_behave_like "Allow Creating"
|
68
33
|
it_should_behave_like "Allow Reading"
|
69
|
-
it_should_behave_like "Allow Destroying"
|
70
34
|
end
|
71
35
|
end
|
72
36
|
|
73
|
-
describe "
|
74
|
-
before do
|
75
|
-
|
37
|
+
describe "in custom relation mode" do
|
38
|
+
before :all do
|
39
|
+
SocialStream.relation_model = :custom
|
40
|
+
end
|
76
41
|
|
77
|
-
|
78
|
-
@
|
79
|
-
|
80
|
-
:user_author_id => @user.actor_id)
|
42
|
+
before do
|
43
|
+
@user = Factory(:user)
|
44
|
+
sign_in @user
|
81
45
|
end
|
82
46
|
|
83
|
-
|
84
|
-
|
85
|
-
|
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
|
86
58
|
|
87
|
-
|
88
|
-
|
89
|
-
|
59
|
+
it_should_behave_like "Allow Creating"
|
60
|
+
it_should_behave_like "Allow Reading"
|
61
|
+
it_should_behave_like "Allow Destroying"
|
90
62
|
|
91
|
-
|
92
|
-
|
63
|
+
it "should destroy with js" do
|
64
|
+
count = model_count
|
65
|
+
delete :destroy, :id => @current_model.to_param, :format => :js
|
93
66
|
|
94
|
-
|
95
|
-
end
|
67
|
+
resource = assigns(model_sym)
|
96
68
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
end
|
69
|
+
model_count.should eq(count - 1)
|
70
|
+
end
|
71
|
+
end
|
101
72
|
|
102
|
-
|
103
|
-
|
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
|
104
83
|
|
105
|
-
|
106
|
-
|
107
|
-
|
84
|
+
it_should_behave_like "Allow Creating"
|
85
|
+
it_should_behave_like "Allow Reading"
|
86
|
+
it_should_behave_like "Allow Destroying"
|
87
|
+
end
|
88
|
+
|
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
|
108
103
|
end
|
109
104
|
|
110
|
-
describe "
|
105
|
+
describe "post to friend" do
|
111
106
|
before do
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
:user_author_id => contact.sender.id,
|
119
|
-
:_relation_ids => Array(relation.id))
|
107
|
+
friend = Factory(:friend, :contact => Factory(:contact, :receiver => @user.actor)).sender
|
108
|
+
|
109
|
+
model_assigned_to @user.contact_to!(friend), friend.relation_custom('friend')
|
110
|
+
@current_model = Factory(:post, :author_id => @user.actor_id,
|
111
|
+
:owner_id => friend.id,
|
112
|
+
:user_author_id => @user.actor_id)
|
120
113
|
end
|
121
114
|
|
122
115
|
it_should_behave_like "Allow Creating"
|
123
116
|
it_should_behave_like "Allow Reading"
|
124
|
-
it_should_behave_like "Allow Destroying"
|
125
117
|
end
|
126
118
|
|
127
|
-
|
119
|
+
describe "post to acquaintance" do
|
128
120
|
before do
|
129
|
-
|
121
|
+
ac = Factory(:acquaintance, :contact => Factory(:contact, :receiver => @user.actor)).sender
|
122
|
+
|
123
|
+
model_assigned_to @user.contact_to!(ac), ac.relation_custom('acquaintance')
|
130
124
|
end
|
131
125
|
|
132
|
-
|
133
|
-
|
134
|
-
contact = @group.contact_to!(@group)
|
135
|
-
relation = @group.relation_customs.sort.first
|
136
|
-
model_assigned_to contact, relation
|
137
|
-
@current_model = Factory(:post, :author_id => contact.sender.id,
|
138
|
-
:owner_id => contact.receiver.id,
|
139
|
-
:user_author_id => contact.sender.id,
|
140
|
-
:_relation_ids => Array(relation.id))
|
141
|
-
end
|
126
|
+
it_should_behave_like "Deny Creating"
|
127
|
+
end
|
142
128
|
|
143
|
-
|
144
|
-
|
145
|
-
|
129
|
+
describe "post from other user" do
|
130
|
+
before do
|
131
|
+
@current_model = Factory(:post)
|
146
132
|
end
|
147
133
|
|
148
|
-
|
134
|
+
|
135
|
+
it_should_behave_like "Deny Reading"
|
136
|
+
end
|
137
|
+
|
138
|
+
describe "posts represented group" do
|
139
|
+
before do
|
140
|
+
@group = Factory(:member, :contact => Factory(:group_contact, :receiver => @user.actor)).sender_subject
|
141
|
+
end
|
142
|
+
|
143
|
+
describe "with member relation" do
|
149
144
|
before do
|
150
|
-
contact = @
|
151
|
-
relation = @group.
|
145
|
+
contact = @user.contact_to!(@group)
|
146
|
+
relation = @group.relation_custom('member')
|
147
|
+
|
152
148
|
model_assigned_to contact, relation
|
153
149
|
@current_model = Factory(:post, :author_id => contact.sender.id,
|
154
|
-
|
155
|
-
|
156
|
-
|
150
|
+
:owner_id => contact.receiver.id,
|
151
|
+
:user_author_id => contact.sender.id,
|
152
|
+
:_relation_ids => Array(relation.id))
|
157
153
|
end
|
158
154
|
|
159
155
|
it_should_behave_like "Allow Creating"
|
@@ -161,91 +157,128 @@ describe PostsController do
|
|
161
157
|
it_should_behave_like "Allow Destroying"
|
162
158
|
end
|
163
159
|
|
164
|
-
|
160
|
+
context "representing the group" do
|
165
161
|
before do
|
166
|
-
|
167
|
-
relation = Relation::Public.instance
|
168
|
-
model_assigned_to contact, relation
|
169
|
-
@current_model = Factory(:post, :author_id => contact.sender.id,
|
170
|
-
:owner_id => contact.receiver.id,
|
171
|
-
:user_author_id => contact.sender.id,
|
172
|
-
:_relation_ids => Array(relation.id))
|
162
|
+
represent(@group)
|
173
163
|
end
|
174
164
|
|
175
|
-
|
176
|
-
|
177
|
-
|
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
|
180
|
+
|
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"
|
195
|
+
end
|
196
|
+
|
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
|
178
212
|
end
|
179
213
|
end
|
180
214
|
end
|
181
|
-
end
|
182
215
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
216
|
+
context "creating post in group's wall" do
|
217
|
+
before do
|
218
|
+
@tie = Factory(:member)
|
219
|
+
end
|
187
220
|
|
188
|
-
|
189
|
-
|
221
|
+
it "should assign activity to member" do
|
222
|
+
sign_in @tie.receiver_subject
|
190
223
|
|
191
|
-
|
192
|
-
|
193
|
-
|
224
|
+
post :create, :post => { :text => "Test",
|
225
|
+
:owner_id => @tie.contact.sender.id
|
226
|
+
}
|
194
227
|
|
195
|
-
|
228
|
+
post = assigns(:post)
|
196
229
|
|
197
|
-
|
198
|
-
|
199
|
-
|
230
|
+
post.should be_valid
|
231
|
+
post.post_activity.relations.should include(@tie.relation)
|
232
|
+
end
|
200
233
|
|
201
|
-
|
202
|
-
|
234
|
+
it "should assign activity to member" do
|
235
|
+
sign_in @tie.receiver_subject
|
203
236
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
237
|
+
post :create, :post => { :text => "Test",
|
238
|
+
:owner_id => @tie.contact.sender.id
|
239
|
+
},
|
240
|
+
:format => :js
|
209
241
|
|
210
|
-
post = assigns(:post)
|
211
242
|
|
212
|
-
|
213
|
-
post.post_activity.relations.should include(@tie.relation)
|
243
|
+
post = assigns(:post)
|
214
244
|
|
215
|
-
|
216
|
-
|
217
|
-
end
|
245
|
+
post.should be_valid
|
246
|
+
post.post_activity.relations.should include(@tie.relation)
|
218
247
|
|
219
|
-
|
220
|
-
|
221
|
-
@post = Factory(:public_post)
|
248
|
+
response.should be_success
|
249
|
+
end
|
222
250
|
end
|
223
251
|
|
224
|
-
|
225
|
-
|
252
|
+
context "creating public post" do
|
253
|
+
before do
|
254
|
+
@post = Factory(:public_post)
|
255
|
+
end
|
256
|
+
|
257
|
+
it "should render" do
|
258
|
+
get :show, :id => @post.to_param
|
226
259
|
|
227
|
-
|
260
|
+
response.should be_success
|
261
|
+
end
|
228
262
|
end
|
229
|
-
end
|
230
263
|
|
231
|
-
|
232
|
-
|
233
|
-
|
264
|
+
describe "to friend on representation change" do
|
265
|
+
before do
|
266
|
+
@post = Factory(:post)
|
234
267
|
|
235
|
-
|
268
|
+
@user = @post.post_activity.sender_subject
|
236
269
|
|
237
|
-
|
270
|
+
@group = Factory(:member, :contact => Factory(:g2g_contact, :receiver => @user.actor)).sender_subject
|
238
271
|
|
239
|
-
|
272
|
+
Factory(:friend, :contact => Factory(:g2g_contact, :sender => @user.actor))
|
240
273
|
|
241
|
-
|
242
|
-
|
274
|
+
sign_in @user
|
275
|
+
end
|
243
276
|
|
244
|
-
|
245
|
-
|
277
|
+
it "should redirect show to home" do
|
278
|
+
get :show, :id => @post.to_param, :s => @group.slug
|
246
279
|
|
247
|
-
|
280
|
+
response.should redirect_to(:home)
|
281
|
+
end
|
248
282
|
end
|
249
283
|
end
|
250
284
|
end
|
251
|
-
|