social_stream 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.rdoc +2 -3
- data/app/controllers/likes_controller.rb +2 -2
- data/app/controllers/messages_controller.rb +3 -0
- data/app/controllers/representations_controller.rb +8 -0
- data/app/controllers/ties_controller.rb +1 -1
- data/app/helpers/activities_helper.rb +2 -2
- data/app/helpers/ties_helper.rb +19 -16
- data/app/models/activity.rb +42 -7
- data/app/models/activity_object.rb +1 -0
- data/app/models/activity_verb.rb +5 -1
- data/app/models/actor.rb +113 -68
- data/app/models/group.rb +15 -1
- data/app/models/message.rb +2 -0
- data/app/models/permission.rb +20 -41
- data/app/models/profile.rb +1 -1
- data/app/models/relation.rb +34 -26
- data/app/models/representation.rb +35 -0
- data/app/models/tie.rb +47 -100
- data/app/models/user.rb +12 -17
- data/app/views/activities/_activities.html.erb +2 -2
- data/app/views/activities/_new.html.erb +6 -3
- data/app/views/activities/_options.html.erb +1 -1
- data/app/views/comments/_new.html.erb +2 -2
- data/app/views/frontpage/index.html.erb +0 -2
- data/app/views/groups/_group.html.erb +3 -3
- data/app/views/groups/_index.html.erb +3 -4
- data/app/views/groups/_middle_show.html.erb +7 -4
- data/app/views/groups/_new.html.erb +25 -0
- data/app/views/groups/_right_show.html.erb +4 -2
- data/app/views/groups/new.html.erb +1 -0
- data/app/views/groups/show.html.erb +1 -1
- data/app/views/home/_groups.html.erb +7 -5
- data/app/views/home/_location.html.erb +1 -1
- data/app/views/home/_options.html.erb +2 -2
- data/app/views/home/_right.html.erb +2 -2
- data/app/views/home/index.html.erb +6 -2
- data/app/views/layouts/_footer.html.erb +1 -1
- data/app/views/layouts/_header.erb +4 -1
- data/app/views/layouts/_representation.html.erb +20 -0
- data/app/views/{private_messages → messages}/_form.html.erb +4 -4
- data/app/views/{private_messages → messages}/_index.html.erb +1 -1
- data/app/views/{private_messages → messages}/_location.html.erb +1 -1
- data/app/views/messages/_message.html.erb +17 -0
- data/app/views/messages/_messages.html.erb +2 -0
- data/app/views/messages/edit.html.erb +6 -0
- data/app/views/{private_messages → messages}/index.html.erb +0 -0
- data/app/views/{private_messages → messages}/index.js.erb +0 -0
- data/app/views/{private_messages → messages}/new.html.erb +2 -2
- data/app/views/messages/show.html.erb +21 -0
- data/app/views/subjects/_contacts.html.erb +20 -0
- data/app/views/ties/_new.html.erb +6 -6
- data/app/views/ties/_pendings.html.erb +3 -3
- data/app/views/ties/_suggestions.html.erb +3 -3
- data/app/views/ties/_tie.html.erb +1 -1
- data/app/views/ties/create.js.erb +4 -5
- data/app/views/ties/new.js.erb +1 -1
- data/app/views/users/_groups.html.erb +5 -5
- data/app/views/users/_index.html.erb +3 -1
- data/app/views/users/_options.html.erb +1 -1
- data/app/views/users/_right_show.html.erb +3 -3
- data/app/views/users/show.html.erb +5 -3
- data/config/locales/en.yml +13 -19
- data/config/routes.rb +11 -4
- data/lib/generators/social_stream/install_generator.rb +2 -10
- data/lib/generators/social_stream/templates/initializer.rb +1 -1
- data/lib/generators/social_stream/templates/migration.rb +19 -24
- data/lib/generators/social_stream/templates/public/javascripts/jquery.js +6883 -0
- data/lib/generators/social_stream/templates/public/javascripts/rails.js +146 -0
- data/lib/generators/social_stream/templates/public/javascripts/ui.dropdownchecklist.js +3 -13
- data/lib/generators/social_stream/templates/public/stylesheets/header.css +5 -1
- data/lib/generators/social_stream/templates/public/{images → stylesheets/images}/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/generators/social_stream/templates/public/{images → stylesheets/images}/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/lib/generators/social_stream/templates/public/{images → stylesheets/images}/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/{images → stylesheets/images}/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/{images → stylesheets/images}/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/{images → stylesheets/images}/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/{images → stylesheets/images}/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/{images → stylesheets/images}/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/lib/generators/social_stream/templates/public/{images → stylesheets/images}/ui-icons_222222_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/{images → stylesheets/images}/ui-icons_2e83ff_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/{images → stylesheets/images}/ui-icons_454545_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/{images → stylesheets/images}/ui-icons_888888_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/{images → stylesheets/images}/ui-icons_cd0a0a_256x240.png +0 -0
- data/lib/generators/social_stream/templates/relations.yml +42 -0
- data/lib/social_stream/ability.rb +7 -6
- data/lib/social_stream/controllers/helpers.rb +35 -0
- data/lib/social_stream/models/{activity_object.rb → object.rb} +1 -1
- data/lib/social_stream/models/{actor.rb → subject.rb} +10 -30
- data/lib/social_stream/models/supertype.rb +5 -2
- data/lib/social_stream/rails.rb +25 -6
- data/lib/social_stream/relations.rb +46 -0
- data/lib/social_stream/version.rb +1 -1
- data/lib/social_stream.rb +13 -13
- data/lib/tasks/db/populate.rake +23 -29
- data/spec/controllers/groups_controller_spec.rb +2 -6
- data/spec/controllers/ties_controller_spec.rb +19 -0
- data/spec/controllers/users_controller_spec.rb +0 -2
- data/spec/dummy/config/application.rb +0 -1
- data/spec/dummy/config/initializers/social_stream.rb +14 -2
- data/spec/dummy/config/relations.yml +42 -0
- data/spec/dummy/db/schema.rb +9 -0
- data/spec/dummy/db/seeds.rb +0 -1
- data/spec/factories/activity.rb +2 -2
- data/spec/factories/actor.rb +2 -1
- data/spec/factories/group.rb +1 -0
- data/spec/factories/post.rb +1 -1
- data/spec/factories/tie.rb +16 -22
- data/spec/models/activity_spec.rb +27 -24
- data/spec/models/actor_spec.rb +3 -0
- data/spec/models/representation_spec.rb +16 -0
- data/spec/models/tie_spec.rb +49 -57
- data/spec/models/user_spec.rb +22 -0
- data/spec/support/db.rb +1 -1
- metadata +47 -45
- data/Gemfile.lock +0 -171
- data/app/controllers/private_messages_controller.rb +0 -3
- data/app/models/private_message.rb +0 -6
- data/app/views/groups/_follow.html.erb +0 -9
- data/app/views/groups/_followers.html.erb +0 -16
- data/app/views/home/_contacts.html.erb +0 -17
- data/app/views/private_messages/_messages.html.erb +0 -2
- data/app/views/private_messages/_private_message.html.erb +0 -17
- data/app/views/private_messages/edit.html.erb +0 -6
- data/app/views/private_messages/show.html.erb +0 -21
- data/app/views/ties/_pending.html.erb +0 -21
- data/app/views/users/_contacts.html.erb +0 -19
- data/init.rb +0 -3
- data/lib/generators/social_stream/templates/seeds.yml +0 -64
- data/lib/social_stream/rails/common.rb +0 -36
- data/lib/social_stream/rails/engine.rb +0 -9
- data/lib/social_stream/rails/railtie.rb +0 -9
- data/lib/social_stream/seed.rb +0 -49
- data/spec/dummy/db/seeds/social_stream.yml +0 -64
- data/spec/models/user_space.rb +0 -10
@@ -5,16 +5,12 @@ describe GroupsController do
|
|
5
5
|
|
6
6
|
describe "when Anonymous" do
|
7
7
|
it "should render index" do
|
8
|
-
pending
|
9
|
-
|
10
8
|
get :index
|
11
9
|
|
12
10
|
assert_response :success
|
13
11
|
end
|
14
12
|
|
15
13
|
it "should render show" do
|
16
|
-
pending
|
17
|
-
|
18
14
|
get :show, :id => Factory(:group).to_param
|
19
15
|
|
20
16
|
assert_response :success
|
@@ -34,8 +30,8 @@ describe GroupsController do
|
|
34
30
|
assert_response :success
|
35
31
|
end
|
36
32
|
|
37
|
-
it "should render
|
38
|
-
@group = Factory(:member, :
|
33
|
+
it "should render contact group" do
|
34
|
+
@group = Factory(:member, :receiver => @user.actor).sender_subject
|
39
35
|
get :show, :id => @group.to_param
|
40
36
|
|
41
37
|
assert_response :success
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe TiesController do
|
4
|
+
render_views
|
5
|
+
|
6
|
+
describe "when authenticated" do
|
7
|
+
before do
|
8
|
+
@user = Factory(:user)
|
9
|
+
|
10
|
+
sign_in @user
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should render new" do
|
14
|
+
get :new, :tie => Factory.attributes_for(:friend, :sender => @user.actor)
|
15
|
+
|
16
|
+
assert_response :success
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -21,7 +21,6 @@ module Dummy
|
|
21
21
|
# Only load the plugins named here, in the order given (default is alphabetical).
|
22
22
|
# :all can be used as a placeholder for all plugins not explicitly named.
|
23
23
|
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
24
|
-
config.paths.vendor.plugins "../../.."
|
25
24
|
|
26
25
|
# Activate observers that should always be running.
|
27
26
|
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
@@ -1,5 +1,17 @@
|
|
1
1
|
SocialStream.setup do |config|
|
2
|
-
|
2
|
+
# List the models that are social entities. These will have ties between them.
|
3
|
+
# Remember you must add an "actor_id" foreign key column to your migration!
|
4
|
+
#
|
5
|
+
# config.actors = [:user, :group ]
|
3
6
|
|
4
|
-
|
7
|
+
# Include devise modules in User. See devise documentation for details.
|
8
|
+
# Others available are:
|
9
|
+
# :token_authenticatable, :confirmable, :lockable, :timeoutable, :validatable
|
10
|
+
# config.devise_modules :database_authenticatable, :registerable,
|
11
|
+
# :recoverable, :rememberable, :trackable
|
12
|
+
|
13
|
+
# Type of activities managed by actors
|
14
|
+
# Remember you must add an "activity_object_id" foreign key column to your migration!
|
15
|
+
#
|
16
|
+
# config.activity_objects = [ :post, :comment, :messages ]
|
5
17
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Relations for Social Stream
|
2
|
+
#
|
3
|
+
# Define the relations and permissions supported by your application
|
4
|
+
#
|
5
|
+
user:
|
6
|
+
friend:
|
7
|
+
name: friend
|
8
|
+
permissions:
|
9
|
+
- [ create, activity, weak_set ]
|
10
|
+
- [ read, activity, star_set ]
|
11
|
+
- [ update, activity, weak_set ]
|
12
|
+
- [ destroy, activity, weak_set ]
|
13
|
+
acquaintance:
|
14
|
+
name: acquaintance
|
15
|
+
parent: friend
|
16
|
+
permissions:
|
17
|
+
- [ read, activity, star_set ]
|
18
|
+
public:
|
19
|
+
name: public
|
20
|
+
parent: acquaintance
|
21
|
+
permissions:
|
22
|
+
- [ read, activity, star_set ]
|
23
|
+
|
24
|
+
group:
|
25
|
+
member:
|
26
|
+
name: member
|
27
|
+
permissions:
|
28
|
+
- [ represent ]
|
29
|
+
- [ create, activity, weak_set ]
|
30
|
+
- [ read, activity, star_set ]
|
31
|
+
- [ update, activity, weak_star_set ]
|
32
|
+
- [ destroy, activity, weak_star_set ]
|
33
|
+
partner:
|
34
|
+
name: partner
|
35
|
+
parent: member
|
36
|
+
permissions:
|
37
|
+
- [ read, activity, star_set ]
|
38
|
+
public:
|
39
|
+
name: public
|
40
|
+
parent: partner
|
41
|
+
permissions:
|
42
|
+
- [ read, activity, star_set ]
|
data/spec/dummy/db/seeds.rb
CHANGED
data/spec/factories/activity.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
Factory.define :activity do |a|
|
2
|
-
a.association :_tie, :factory => :
|
2
|
+
a.association :_tie, :factory => :friend
|
3
3
|
a.activity_verb { ActivityVerb["post"] }
|
4
4
|
end
|
5
5
|
|
6
6
|
Factory.define :like_activity, :parent => :activity do |a|
|
7
7
|
a.association :parent, :factory => :activity
|
8
8
|
a.activity_verb { ActivityVerb["like"] }
|
9
|
-
a._tie { |tie| tie.association(:
|
9
|
+
a._tie { |tie| tie.association(:friend, :sender => tie.parent.tie.sender) }
|
10
10
|
end
|
data/spec/factories/actor.rb
CHANGED
data/spec/factories/group.rb
CHANGED
data/spec/factories/post.rb
CHANGED
data/spec/factories/tie.rb
CHANGED
@@ -1,43 +1,37 @@
|
|
1
1
|
Factory.define :tie do |t|
|
2
|
-
t.sender
|
2
|
+
t.sender { |s| Factory(:user).actor }
|
3
3
|
t.receiver { |r| Factory(:user).actor }
|
4
|
-
t.relation { |r| Relation.mode('User', 'User').strongest }
|
5
4
|
end
|
6
5
|
|
7
|
-
#
|
6
|
+
# User ties
|
8
7
|
|
9
8
|
Factory.define :friend, :parent => :tie do |t|
|
10
|
-
t.
|
9
|
+
t.after_build { |u| u.relation = u.sender.relation('friend') }
|
11
10
|
end
|
12
11
|
|
13
|
-
Factory.define :
|
14
|
-
t.
|
12
|
+
Factory.define :acquaintance, :parent => :tie do |t|
|
13
|
+
t.after_build { |u| u.relation = u.sender.relation('acquaintance') }
|
15
14
|
end
|
16
15
|
|
17
16
|
Factory.define :public, :parent => :tie do |t|
|
18
|
-
t.
|
17
|
+
t.after_build { |u| u.relation = u.sender.relation('public') }
|
19
18
|
end
|
20
19
|
|
21
|
-
#
|
22
|
-
Factory.define :
|
23
|
-
t.
|
24
|
-
t.relation { |r| Relation.mode('User', 'Group').strongest }
|
20
|
+
# Group ties
|
21
|
+
Factory.define :g2u_tie, :parent => :tie do |t|
|
22
|
+
t.sender { |u| Factory(:group).actor }
|
25
23
|
end
|
26
24
|
|
27
|
-
Factory.define :member, :parent => :
|
28
|
-
t.
|
25
|
+
Factory.define :member, :parent => :g2u_tie do |t|
|
26
|
+
t.after_build { |u| u.relation = u.sender.relation('member') }
|
29
27
|
end
|
30
28
|
|
31
|
-
Factory.define :
|
32
|
-
t.
|
29
|
+
Factory.define :g2g_tie, :parent => :tie do |t|
|
30
|
+
t.sender { |u| Factory(:group).actor }
|
31
|
+
t.receiver { |u| Factory(:group).actor }
|
33
32
|
end
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
t.sender { |r| Factory(:group).actor }
|
38
|
-
t.relation { |r| Relation.mode('Group', 'User').strongest }
|
34
|
+
Factory.define :partner, :parent => :g2g_tie do |t|
|
35
|
+
t.after_build { |u| u.relation = u.sender.relation('partner') }
|
39
36
|
end
|
40
37
|
|
41
|
-
Factory.define :g2u_member, :parent => :tie do |t|
|
42
|
-
t.relation { |r| Relation.mode('Group', 'User').find_by_name('member') }
|
43
|
-
end
|
@@ -7,13 +7,13 @@ module ActivityTestHelper
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def create_ability_accessed_by(tie_type)
|
10
|
-
t = Factory(tie_type, :
|
11
|
-
u = t.
|
10
|
+
t = Factory(tie_type, :sender => @tie.sender)
|
11
|
+
u = t.receiver_subject
|
12
12
|
@ability = Ability.new(u)
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
16
|
-
u = @tie.
|
15
|
+
def create_ability_accessed_by_receiver
|
16
|
+
u = @tie.receiver_subject
|
17
17
|
@ability = Ability.new(u)
|
18
18
|
end
|
19
19
|
|
@@ -96,7 +96,7 @@ describe Activity do
|
|
96
96
|
|
97
97
|
describe "accessed by sender" do
|
98
98
|
before do
|
99
|
-
|
99
|
+
create_ability_accessed_by_receiver
|
100
100
|
end
|
101
101
|
|
102
102
|
it_should_behave_like "Allows Creating"
|
@@ -116,11 +116,12 @@ describe Activity do
|
|
116
116
|
it_should_behave_like "Denies Destroying"
|
117
117
|
end
|
118
118
|
|
119
|
-
describe "accessed by
|
119
|
+
describe "accessed by acquaintance" do
|
120
120
|
before do
|
121
|
-
create_ability_accessed_by :
|
121
|
+
create_ability_accessed_by :acquaintance
|
122
122
|
end
|
123
123
|
|
124
|
+
|
124
125
|
it_should_behave_like "Denies Creating"
|
125
126
|
it_should_behave_like "Denies Reading"
|
126
127
|
it_should_behave_like "Denies Updating"
|
@@ -139,15 +140,16 @@ describe Activity do
|
|
139
140
|
end
|
140
141
|
end
|
141
142
|
|
142
|
-
describe "belonging to friend
|
143
|
+
describe "belonging to friend self tie" do
|
143
144
|
before do
|
144
|
-
|
145
|
+
user = Factory(:user)
|
146
|
+
tie = user.ties.where(:relation_id => user.relation('friend')).first
|
145
147
|
create_activity_assigned_to(tie)
|
146
148
|
end
|
147
149
|
|
148
150
|
describe "accessed by the sender" do
|
149
151
|
before do
|
150
|
-
|
152
|
+
create_ability_accessed_by_receiver
|
151
153
|
end
|
152
154
|
|
153
155
|
it_should_behave_like "Allows Creating"
|
@@ -167,9 +169,9 @@ describe Activity do
|
|
167
169
|
it_should_behave_like "Denies Destroying"
|
168
170
|
end
|
169
171
|
|
170
|
-
describe "accessed by
|
172
|
+
describe "accessed by acquaintance" do
|
171
173
|
before do
|
172
|
-
create_ability_accessed_by :
|
174
|
+
create_ability_accessed_by :acquaintance
|
173
175
|
end
|
174
176
|
|
175
177
|
it_should_behave_like "Denies Creating"
|
@@ -193,13 +195,14 @@ describe Activity do
|
|
193
195
|
describe "belonging to public tie" do
|
194
196
|
|
195
197
|
before do
|
196
|
-
|
198
|
+
user = Factory(:user)
|
199
|
+
tie = user.ties.where(:relation_id => user.relation('public')).first
|
197
200
|
create_activity_assigned_to(tie)
|
198
201
|
end
|
199
202
|
|
200
203
|
describe "accessed by the sender" do
|
201
204
|
before do
|
202
|
-
|
205
|
+
create_ability_accessed_by_receiver
|
203
206
|
end
|
204
207
|
|
205
208
|
it_should_behave_like "Allows Creating"
|
@@ -219,9 +222,9 @@ describe Activity do
|
|
219
222
|
it_should_behave_like "Denies Destroying"
|
220
223
|
end
|
221
224
|
|
222
|
-
describe "accessed by
|
225
|
+
describe "accessed by acquaintance" do
|
223
226
|
before do
|
224
|
-
create_ability_accessed_by :
|
227
|
+
create_ability_accessed_by :acquaintance
|
225
228
|
end
|
226
229
|
|
227
230
|
it_should_behave_like "Denies Creating"
|
@@ -246,7 +249,7 @@ describe Activity do
|
|
246
249
|
|
247
250
|
before do
|
248
251
|
create_activity_assigned_to(Factory(:public))
|
249
|
-
|
252
|
+
create_ability_accessed_by_receiver
|
250
253
|
end
|
251
254
|
|
252
255
|
it_should_behave_like "Denies Creating"
|
@@ -259,7 +262,7 @@ describe Activity do
|
|
259
262
|
|
260
263
|
describe "accessed by same member" do
|
261
264
|
before do
|
262
|
-
|
265
|
+
create_ability_accessed_by_receiver
|
263
266
|
end
|
264
267
|
|
265
268
|
it_should_behave_like "Allows Creating"
|
@@ -279,9 +282,9 @@ describe Activity do
|
|
279
282
|
it_should_behave_like "Allows Destroying"
|
280
283
|
end
|
281
284
|
|
282
|
-
describe "accessed by
|
285
|
+
describe "accessed by partner" do
|
283
286
|
before do
|
284
|
-
create_ability_accessed_by :
|
287
|
+
create_ability_accessed_by :partner
|
285
288
|
end
|
286
289
|
|
287
290
|
it_should_behave_like "Denies Creating"
|
@@ -302,7 +305,7 @@ describe Activity do
|
|
302
305
|
end
|
303
306
|
end
|
304
307
|
|
305
|
-
describe "belonging to public tie from
|
308
|
+
describe "belonging to public tie from a member" do
|
306
309
|
|
307
310
|
before do
|
308
311
|
create_activity_assigned_to(Factory(:member).related('public'))
|
@@ -310,7 +313,7 @@ describe Activity do
|
|
310
313
|
|
311
314
|
describe "accessed by sender" do
|
312
315
|
before do
|
313
|
-
|
316
|
+
create_ability_accessed_by_receiver
|
314
317
|
end
|
315
318
|
|
316
319
|
it_should_behave_like "Allows Creating"
|
@@ -331,9 +334,9 @@ describe Activity do
|
|
331
334
|
end
|
332
335
|
|
333
336
|
|
334
|
-
describe "accessed by
|
337
|
+
describe "accessed by partner" do
|
335
338
|
before do
|
336
|
-
create_ability_accessed_by :
|
339
|
+
create_ability_accessed_by :partner
|
337
340
|
end
|
338
341
|
|
339
342
|
it_should_behave_like "Denies Creating"
|
data/spec/models/actor_spec.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe Representation do
|
4
|
+
describe "initialized with" do
|
5
|
+
describe "valid subject" do
|
6
|
+
before do
|
7
|
+
@group = Factory(:group)
|
8
|
+
@dom_id = ActionController::RecordIdentifier.dom_id(@group)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should find subject" do
|
12
|
+
assert_equal @group, Representation.new(:subject_dom_id => @dom_id).subject
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/spec/models/tie_spec.rb
CHANGED
@@ -1,30 +1,27 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
3
|
describe Tie do
|
4
|
-
it "should
|
4
|
+
it "should create from relation name" do
|
5
5
|
relation = Relation.first
|
6
6
|
sender = Factory(relation.sender_type.underscore)
|
7
|
-
|
7
|
+
|
8
|
+
receiver_type = relation.receiver_type.present? ?
|
9
|
+
relation.receiver_type :
|
10
|
+
relation.sender_type
|
11
|
+
|
12
|
+
receiver = Factory(receiver_type.underscore)
|
8
13
|
|
9
14
|
tie = Factory(:tie, :sender_id => sender.actor.id,
|
10
15
|
:receiver_id => receiver.actor.id,
|
11
16
|
:relation_name => relation.name)
|
12
17
|
tie.should be_valid
|
13
|
-
|
14
18
|
end
|
15
19
|
|
16
|
-
|
17
|
-
|
18
|
-
@relation = Relation.where("inverse_id IS NOT NULL").first
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should have its inverse tie" do
|
22
|
-
@tie = Factory(:tie, :relation => @relation)
|
20
|
+
it "should create pending" do
|
21
|
+
tie = Factory(:friend)
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
@relation.inverse).present?
|
27
|
-
end
|
23
|
+
assert tie.receiver.pending_ties.present?
|
24
|
+
assert tie.receiver.pending_ties.first.relation_set.blank?
|
28
25
|
end
|
29
26
|
|
30
27
|
describe "friend" do
|
@@ -32,65 +29,52 @@ describe Tie do
|
|
32
29
|
@tie = Factory(:friend)
|
33
30
|
end
|
34
31
|
|
35
|
-
describe ",
|
32
|
+
describe ", receiver" do
|
36
33
|
before do
|
37
|
-
@s = @tie.
|
34
|
+
@s = @tie.receiver
|
38
35
|
end
|
39
36
|
|
40
37
|
it "creates activity" do
|
41
|
-
Tie.
|
42
|
-
Tie.
|
43
|
-
Tie.allowed(@s, 'create', 'activity').should_not include(@tie.inverse)
|
44
|
-
Tie.allowed(@s, 'create', 'activity').should_not include(@tie.inverse.related('public'))
|
38
|
+
Tie.allowing(@s, 'create', 'activity').should include(@tie)
|
39
|
+
Tie.allowing(@s, 'create', 'activity').should include(@tie.related('public'))
|
45
40
|
end
|
46
41
|
|
47
42
|
it "reads activity" do
|
48
|
-
Tie.
|
49
|
-
Tie.
|
50
|
-
Tie.allowed(@s, 'read', 'activity').should include(@tie.inverse)
|
51
|
-
Tie.allowed(@s, 'read', 'activity').should include(@tie.inverse.related('public'))
|
43
|
+
Tie.allowing(@s, 'read', 'activity').should include(@tie)
|
44
|
+
Tie.allowing(@s, 'read', 'activity').should include(@tie.related('public'))
|
52
45
|
end
|
53
46
|
end
|
54
47
|
|
55
48
|
describe ", friend" do
|
56
49
|
before do
|
57
|
-
@s = @tie.receiver
|
50
|
+
@s = Factory(:friend, :sender => @tie.sender).receiver
|
58
51
|
end
|
59
52
|
|
60
53
|
it "creates activity" do
|
61
|
-
Tie.
|
62
|
-
Tie.
|
63
|
-
Tie.allowed(@s, 'create', 'activity').should_not include(@tie)
|
64
|
-
Tie.allowed(@s, 'create', 'activity').should_not include(@tie.related('public'))
|
54
|
+
Tie.allowing(@s, 'create', 'activity').should_not include(@tie)
|
55
|
+
Tie.allowing(@s, 'create', 'activity').should_not include(@tie.related('public'))
|
65
56
|
end
|
66
57
|
|
67
58
|
it "reads activity" do
|
68
|
-
Tie.
|
69
|
-
Tie.
|
70
|
-
Tie.allowed(@s, 'read', 'activity').should include(@tie.inverse)
|
71
|
-
Tie.allowed(@s, 'read', 'activity').should include(@tie.inverse.related('public'))
|
59
|
+
Tie.allowing(@s, 'read', 'activity').should include(@tie)
|
60
|
+
Tie.allowing(@s, 'read', 'activity').should include(@tie.related('public'))
|
72
61
|
end
|
73
62
|
end
|
74
63
|
|
75
|
-
describe ",
|
64
|
+
describe ", acquaintance" do
|
76
65
|
before do
|
77
|
-
@s = Factory(:
|
66
|
+
@s = Factory(:acquaintance, :receiver => @tie.receiver).sender
|
78
67
|
end
|
79
68
|
|
80
69
|
it "creates activity" do
|
81
|
-
Tie.
|
82
|
-
Tie.
|
83
|
-
Tie.allowed(@s, 'create', 'activity').should_not include(@tie.inverse)
|
84
|
-
Tie.allowed(@s, 'create', 'activity').should_not include(@tie.inverse.related('public'))
|
70
|
+
Tie.allowing(@s, 'create', 'activity').should_not include(@tie)
|
71
|
+
Tie.allowing(@s, 'create', 'activity').should_not include(@tie.related('public'))
|
85
72
|
end
|
86
73
|
|
87
74
|
it "reads activity" do
|
88
|
-
Tie.
|
89
|
-
# Tie.
|
90
|
-
Tie.allowed(@s, 'read', 'activity').should_not include(@tie.inverse)
|
91
|
-
# Tie.allowed(@s, 'read', 'activity').should_not include(@tie.inverse.related('public'))
|
75
|
+
Tie.allowing(@s, 'read', 'activity').should_not include(@tie)
|
76
|
+
# Tie.allowing(@s, 'read', 'activity').should_not include(@tie.related('public'))
|
92
77
|
end
|
93
|
-
|
94
78
|
end
|
95
79
|
|
96
80
|
describe ", alien" do
|
@@ -99,15 +83,13 @@ describe Tie do
|
|
99
83
|
end
|
100
84
|
|
101
85
|
it "creates activity" do
|
102
|
-
Tie.
|
103
|
-
Tie.
|
104
|
-
Tie.allowed(@s, 'create', 'activity').should_not include(@tie.inverse)
|
105
|
-
Tie.allowed(@s, 'create', 'activity').should_not include(@tie.inverse.related('public'))
|
86
|
+
Tie.allowing(@s, 'create', 'activity').should_not include(@tie)
|
87
|
+
Tie.allowing(@s, 'create', 'activity').should_not include(@tie.related('public'))
|
106
88
|
end
|
107
89
|
|
108
90
|
it "reads activity" do
|
109
|
-
Tie.
|
110
|
-
Tie.
|
91
|
+
Tie.allowing(@s, 'read', 'activity').should_not include(@tie)
|
92
|
+
Tie.allowing(@s, 'read', 'activity').should include(@tie.related('public'))
|
111
93
|
end
|
112
94
|
end
|
113
95
|
end
|
@@ -117,25 +99,35 @@ describe Tie do
|
|
117
99
|
@tie = Factory(:member)
|
118
100
|
end
|
119
101
|
|
120
|
-
describe ",
|
102
|
+
describe ", receiver" do
|
121
103
|
before do
|
122
|
-
@s = @tie.
|
104
|
+
@s = @tie.receiver
|
123
105
|
end
|
124
106
|
|
125
107
|
it "updates activity" do
|
126
|
-
Tie.
|
127
|
-
Tie.
|
108
|
+
Tie.allowing(@s, 'update', 'activity').should include(@tie)
|
109
|
+
Tie.allowing(@s, 'update', 'activity').should include(@tie.related('public'))
|
128
110
|
end
|
129
111
|
end
|
130
112
|
|
131
113
|
describe ", member" do
|
132
114
|
before do
|
133
|
-
@s = Factory(:member, :
|
115
|
+
@s = Factory(:member, :sender => @tie.sender).receiver
|
116
|
+
end
|
117
|
+
|
118
|
+
it "creates activity" do
|
119
|
+
Tie.allowing(@s, 'create', 'activity').should_not include(@tie)
|
120
|
+
Tie.allowing(@s, 'create', 'activity').should_not include(@tie.related('public'))
|
121
|
+
end
|
122
|
+
|
123
|
+
it "reads activity" do
|
124
|
+
Tie.allowing(@s, 'read', 'activity').should include(@tie)
|
125
|
+
Tie.allowing(@s, 'read', 'activity').should include(@tie.related('public'))
|
134
126
|
end
|
135
127
|
|
136
128
|
it "updates activity" do
|
137
|
-
Tie.
|
138
|
-
Tie.
|
129
|
+
Tie.allowing(@s, 'update', 'activity').should include(@tie)
|
130
|
+
Tie.allowing(@s, 'update', 'activity').should include(@tie.related('public'))
|
139
131
|
end
|
140
132
|
end
|
141
133
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe User do
|
4
|
+
it "should find by permalink" do
|
5
|
+
user = Factory(:user)
|
6
|
+
|
7
|
+
assert user.should == User.find_by_permalink(user.permalink)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should represent" do
|
11
|
+
tie = Factory(:member)
|
12
|
+
group = tie.sender_subject
|
13
|
+
user = tie.receiver_subject
|
14
|
+
|
15
|
+
assert user.represented.should include(group)
|
16
|
+
|
17
|
+
tie = Factory(:partner, :receiver => user.actor)
|
18
|
+
|
19
|
+
assert ! user.represented.include?(tie.sender_subject)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
data/spec/support/db.rb
CHANGED