social_stream 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/api_controller.rb +1 -1
- data/app/controllers/contacts_controller.rb +1 -1
- data/app/controllers/conversations_controller.rb +5 -5
- data/app/controllers/groups_controller.rb +1 -0
- data/app/controllers/likes_controller.rb +17 -5
- data/app/controllers/messages_controller.rb +3 -1
- data/app/controllers/profiles_controller.rb +4 -0
- data/app/controllers/representations_controller.rb +12 -1
- data/app/controllers/tags_controller.rb +15 -0
- data/app/controllers/users_controller.rb +3 -0
- data/app/helpers/activities_helper.rb +13 -6
- data/app/models/activity.rb +53 -52
- data/app/models/activity_object.rb +2 -0
- data/app/models/actor.rb +85 -19
- data/app/models/avatar.rb +2 -1
- data/app/models/like.rb +28 -13
- data/app/models/permission.rb +7 -7
- data/app/models/profile.rb +1 -1
- data/app/models/relation/custom.rb +111 -0
- data/app/models/relation/public.rb +42 -0
- data/app/models/relation.rb +1 -89
- data/app/models/sphere.rb +7 -0
- data/app/models/tie.rb +65 -52
- data/app/models/tie_activity.rb +38 -0
- data/app/views/activities/_new.html.erb +4 -4
- data/app/views/activities/_options.html.erb +2 -2
- data/app/views/actors/_actor.html.erb +0 -0
- data/app/views/avatars/index.html.erb +5 -2
- data/app/views/comments/_new.html.erb +2 -2
- data/app/views/contacts/index.html.erb +5 -1
- data/app/views/conversations/edit.html.erb +4 -0
- data/app/views/conversations/index.html.erb +5 -1
- data/app/views/conversations/show.html.erb +4 -0
- data/app/views/frontpage/index.html.erb +4 -0
- data/app/views/groups/_sidebar_index.html.erb +7 -42
- data/app/views/groups/index.html.erb +3 -0
- data/app/views/groups/new.html.erb +3 -0
- data/app/views/groups/show.html.erb +7 -0
- data/app/views/layouts/_account.html.erb +16 -0
- data/app/views/layouts/_footer.html.erb +1 -1
- data/app/views/layouts/_header.erb +7 -22
- data/app/views/layouts/_representation.html.erb +25 -12
- data/app/views/layouts/application.html.erb +6 -3
- data/app/views/layouts/frontpage.html.erb +1 -1
- data/app/views/likes/create.js.erb +1 -1
- data/app/views/likes/destroy.js.erb +1 -1
- data/app/views/messages/new.html.erb +7 -5
- data/app/views/profiles/_profile.html.erb +20 -0
- data/app/views/profiles/edit.html.erb +42 -0
- data/app/views/profiles/show.html.erb +4 -0
- data/app/views/profiles/update.js.erb +5 -0
- data/app/views/subjects/_toolbar_profile_menu_tie_options.html.erb +3 -1
- data/app/views/ties/_new.html.erb +1 -1
- data/app/views/users/index.html.erb +4 -0
- data/app/views/users/show.html.erb +5 -0
- data/config/locales/en.yml +54 -1
- data/config/routes.rb +3 -1
- data/lib/generators/social_stream/install_generator.rb +2 -1
- data/lib/generators/social_stream/templates/migration.rb +23 -27
- data/lib/generators/social_stream/templates/public/images/btn/error.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/info.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/like.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/nolike.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/success.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/warning.png +0 -0
- data/lib/generators/social_stream/templates/public/javascripts/ajax.paginate.js +12 -19
- data/lib/generators/social_stream/templates/public/javascripts/jquery.validate.js +1 -1
- data/lib/generators/social_stream/templates/public/javascripts/main.js +20 -10
- data/lib/generators/social_stream/templates/public/stylesheets/default/base.css +21 -4
- data/lib/generators/social_stream/templates/public/stylesheets/default/header.css +8 -3
- data/lib/generators/social_stream/templates/relations.yml +7 -13
- data/lib/social_stream/ability.rb +39 -20
- data/lib/social_stream/controllers/helpers.rb +6 -0
- data/lib/social_stream/models/object.rb +8 -4
- data/lib/social_stream/models/subject.rb +6 -0
- data/lib/social_stream/rails.rb +6 -3
- data/lib/social_stream/version.rb +1 -1
- data/lib/tasks/db/populate.rake +11 -1
- data/social_stream.gemspec +7 -8
- data/spec/controllers/comments_controller_spec.rb +6 -2
- data/spec/controllers/posts_controller_spec.rb +93 -5
- data/spec/controllers/profiles_controller_spec.rb +58 -1
- data/spec/controllers/representations_controller_spec.rb +51 -0
- data/spec/controllers/users_controller_spec.rb +28 -0
- data/spec/dummy/config/relations.yml +7 -13
- data/spec/dummy/db/schema.rb +2 -13
- data/spec/factories/tie.rb +1 -1
- data/spec/models/activity_spec.rb +28 -67
- data/spec/models/profile_spec.rb +38 -0
- data/spec/models/tie_activity_spec.rb +88 -31
- data/spec/models/tie_spec.rb +20 -14
- data/spec/support/db.rb +8 -10
- data/spec/support/migrations.rb +24 -0
- metadata +74 -59
@@ -2,6 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
2
|
|
3
3
|
|
4
4
|
describe PostsController do
|
5
|
+
include SocialStream::TestHelpers
|
5
6
|
include SocialStream::TestHelpers::Controllers
|
6
7
|
|
7
8
|
render_views
|
@@ -13,16 +14,46 @@ describe PostsController do
|
|
13
14
|
end
|
14
15
|
|
15
16
|
describe "posts to user" do
|
16
|
-
|
17
|
-
|
17
|
+
describe "with first relation" do
|
18
|
+
before do
|
19
|
+
tie = @user.sent_ties.received_by(@user).related_by(@user.relations.sort.first).first
|
20
|
+
model_assigned_to tie
|
21
|
+
@current_model = Factory(:post, :_activity_tie_id => tie)
|
22
|
+
end
|
23
|
+
|
24
|
+
it_should_behave_like "Allow Creating"
|
25
|
+
it_should_behave_like "Allow Destroying"
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "with last relation" do
|
29
|
+
before do
|
30
|
+
tie = @user.sent_ties.received_by(@user).related_by(@user.relations.sort.last).first
|
31
|
+
model_assigned_to tie
|
32
|
+
@current_model = Factory(:post, :_activity_tie_id => tie)
|
33
|
+
end
|
34
|
+
|
35
|
+
it_should_behave_like "Allow Creating"
|
36
|
+
it_should_behave_like "Allow Destroying"
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "with public relation" do
|
40
|
+
before do
|
41
|
+
tie = @user.sent_ties.received_by(@user).related_by(@user.relation_public).first
|
42
|
+
model_assigned_to tie
|
43
|
+
@current_model = Factory(:post, :_activity_tie_id => tie)
|
44
|
+
end
|
45
|
+
|
46
|
+
it_should_behave_like "Allow Creating"
|
47
|
+
it_should_behave_like "Allow Destroying"
|
18
48
|
end
|
19
49
|
|
20
|
-
it_should_behave_like "Allow Creating"
|
21
50
|
end
|
22
51
|
|
23
52
|
describe "post to friend" do
|
24
53
|
before do
|
25
|
-
|
54
|
+
friend = Factory(:friend, :receiver => @user.actor).sender
|
55
|
+
|
56
|
+
model_assigned_to friend.activity_ties_for(@user).first
|
26
57
|
end
|
27
58
|
|
28
59
|
it_should_behave_like "Allow Creating"
|
@@ -30,12 +61,69 @@ describe PostsController do
|
|
30
61
|
|
31
62
|
describe "post to acquaintance" do
|
32
63
|
before do
|
33
|
-
|
64
|
+
ac = Factory(:acquaintance, :receiver => @user.actor).sender
|
65
|
+
|
66
|
+
model_assigned_to Factory(:friend, :sender => @user.actor, :receiver => ac)
|
34
67
|
end
|
35
68
|
|
36
69
|
it_should_behave_like "Deny Creating"
|
37
70
|
end
|
38
71
|
|
72
|
+
describe "posts represented group" do
|
73
|
+
before do
|
74
|
+
@group = Factory(:member, :receiver_id => @user.actor_id).sender_subject
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "with public relation" do
|
78
|
+
before do
|
79
|
+
tie = @group.activity_ties_for(@user).first
|
80
|
+
model_assigned_to tie
|
81
|
+
@current_model = Factory(:post, :_activity_tie_id => tie)
|
82
|
+
end
|
83
|
+
|
84
|
+
it_should_behave_like "Allow Creating"
|
85
|
+
it_should_behave_like "Allow Destroying"
|
86
|
+
end
|
87
|
+
|
88
|
+
context "representing the group" do
|
89
|
+
before do
|
90
|
+
represent(@group)
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "with first relation" do
|
94
|
+
before do
|
95
|
+
tie = @group.sent_ties.received_by(@group).related_by(@group.relations.sort.first).first
|
96
|
+
model_assigned_to tie
|
97
|
+
@current_model = Factory(:post, :_activity_tie_id => tie)
|
98
|
+
end
|
99
|
+
|
100
|
+
it_should_behave_like "Allow Creating"
|
101
|
+
it_should_behave_like "Allow Destroying"
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "with last relation" do
|
105
|
+
before do
|
106
|
+
tie = @group.sent_ties.received_by(@group).related_by(@group.relations.sort.last).first
|
107
|
+
model_assigned_to tie
|
108
|
+
@current_model = Factory(:post, :_activity_tie_id => tie)
|
109
|
+
end
|
110
|
+
|
111
|
+
it_should_behave_like "Allow Creating"
|
112
|
+
it_should_behave_like "Allow Destroying"
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "with public relation" do
|
116
|
+
before do
|
117
|
+
tie = @group.sent_ties.received_by(@group).related_by(@group.relation_public).first
|
118
|
+
model_assigned_to tie
|
119
|
+
@current_model = Factory(:post, :_activity_tie_id => tie)
|
120
|
+
end
|
121
|
+
|
122
|
+
it_should_behave_like "Allow Creating"
|
123
|
+
it_should_behave_like "Allow Destroying"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
39
127
|
end
|
40
128
|
end
|
41
129
|
|
@@ -21,11 +21,42 @@ describe ProfilesController do
|
|
21
21
|
|
22
22
|
assert_response :success
|
23
23
|
end
|
24
|
+
|
25
|
+
it "should not render others edit" do
|
26
|
+
begin
|
27
|
+
get :edit, :user_id => Factory(:user).to_param
|
28
|
+
|
29
|
+
assert false
|
30
|
+
rescue CanCan::AccessDenied
|
31
|
+
assert true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should update" do
|
36
|
+
put :update, :user_id => @user.to_param, :profile => { :organization => "Social Stream" }
|
37
|
+
|
38
|
+
response.should redirect_to([@user, :profile])
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should not update other's" do
|
42
|
+
begin
|
43
|
+
put :update, :user_id => Factory(:user).to_param, :profile => { :organization => "Social Stream" }
|
44
|
+
|
45
|
+
assert false
|
46
|
+
rescue CanCan::AccessDenied
|
47
|
+
assert true
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
24
51
|
end
|
25
52
|
|
26
53
|
context "for a group" do
|
27
54
|
before do
|
28
|
-
|
55
|
+
membership = Factory(:member)
|
56
|
+
@group = membership.sender_subject
|
57
|
+
@user = membership.receiver_subject
|
58
|
+
|
59
|
+
sign_in @user
|
29
60
|
represent @group
|
30
61
|
end
|
31
62
|
|
@@ -40,6 +71,32 @@ describe ProfilesController do
|
|
40
71
|
|
41
72
|
assert_response :success
|
42
73
|
end
|
74
|
+
|
75
|
+
it "should not render others edit" do
|
76
|
+
begin
|
77
|
+
get :edit, :group_id => Factory(:group).to_param
|
78
|
+
|
79
|
+
assert false
|
80
|
+
rescue CanCan::AccessDenied
|
81
|
+
assert true
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should update" do
|
86
|
+
put :update, :group_id => @group.to_param, :profile => { :organization => "Social Stream" }
|
87
|
+
|
88
|
+
response.should redirect_to([@group, :profile])
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should not update other's" do
|
92
|
+
begin
|
93
|
+
put :update, :group_id => Factory(:group).to_param, :profile => { :organization => "Social Stream" }
|
94
|
+
|
95
|
+
assert false
|
96
|
+
rescue CanCan::AccessDenied
|
97
|
+
assert true
|
98
|
+
end
|
99
|
+
end
|
43
100
|
end
|
44
101
|
end
|
45
102
|
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe RepresentationsController do
|
4
|
+
include ActionController::RecordIdentifier
|
5
|
+
|
6
|
+
describe "create" do
|
7
|
+
context "with logged user" do
|
8
|
+
before do
|
9
|
+
@user = Factory(:user)
|
10
|
+
sign_in @user
|
11
|
+
end
|
12
|
+
|
13
|
+
context "representing herself" do
|
14
|
+
it "should redirect_to root" do
|
15
|
+
post :create, :representation => { :subject_dom_id => dom_id(@user) }
|
16
|
+
|
17
|
+
response.should redirect_to(:root)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "representing own group" do
|
22
|
+
before do
|
23
|
+
@group = Factory(:member, :receiver => @user.actor).sender_subject
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should redirect_to root" do
|
27
|
+
post :create, :representation => { :subject_dom_id => dom_id(@group) }
|
28
|
+
|
29
|
+
response.should redirect_to(:root)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "representing other group" do
|
34
|
+
before do
|
35
|
+
@group = Factory(:group)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should deny access" do
|
39
|
+
begin
|
40
|
+
post :create, :representation => { :subject_dom_id => dom_id(@group) }
|
41
|
+
|
42
|
+
assert false
|
43
|
+
rescue CanCan::AccessDenied
|
44
|
+
assert true
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
@@ -15,6 +15,16 @@ describe UsersController do
|
|
15
15
|
|
16
16
|
assert_response :success
|
17
17
|
end
|
18
|
+
|
19
|
+
it "should not render edit" do
|
20
|
+
begin
|
21
|
+
get :edit, :id => Factory(:user).to_param
|
22
|
+
|
23
|
+
assert false
|
24
|
+
rescue CanCan::AccessDenied
|
25
|
+
assert true
|
26
|
+
end
|
27
|
+
end
|
18
28
|
end
|
19
29
|
|
20
30
|
describe "when authenticated" do
|
@@ -41,6 +51,24 @@ describe UsersController do
|
|
41
51
|
|
42
52
|
assert_response :success
|
43
53
|
end
|
54
|
+
|
55
|
+
it "should render edit page" do
|
56
|
+
pending "Account section"
|
57
|
+
get :edit, :id => @user.to_param
|
58
|
+
|
59
|
+
assert_response :success
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should not render other's edit" do
|
63
|
+
begin
|
64
|
+
get :edit, :id => Factory(:user).to_param
|
65
|
+
|
66
|
+
assert false
|
67
|
+
rescue CanCan::AccessDenied
|
68
|
+
assert true
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
44
72
|
end
|
45
73
|
end
|
46
74
|
|
@@ -12,20 +12,17 @@ user:
|
|
12
12
|
name: friend
|
13
13
|
permissions:
|
14
14
|
- [ follow ] # follow the activities of the friend
|
15
|
-
- [ create, activity
|
15
|
+
- [ create, activity ] # let the friend create activities
|
16
16
|
- [ read, activity, star_ties ] # friend can read activities from the other friends
|
17
|
-
- [ update, activity
|
18
|
-
- [ destroy, activity
|
17
|
+
- [ update, activity ] # update her activities
|
18
|
+
- [ destroy, activity ] # destroy her activities
|
19
|
+
sphere: personal
|
19
20
|
acquaintance:
|
20
21
|
name: acquaintance
|
21
22
|
parent: friend # friend relation is stronger than acquaintance
|
22
23
|
permissions:
|
23
24
|
- [ read, activity, star_ties ]
|
24
|
-
|
25
|
-
name: public
|
26
|
-
parent: acquaintance # acquaintance is stronger than public
|
27
|
-
permissions:
|
28
|
-
- [ read, activity, star_ties ]
|
25
|
+
sphere: personal
|
29
26
|
|
30
27
|
group:
|
31
28
|
member:
|
@@ -37,13 +34,10 @@ group:
|
|
37
34
|
- [ update, activity, weak_star_ties ] # update and destroy activities to members,
|
38
35
|
- [ destroy, activity, weak_star_ties ] # acquaintance and public
|
39
36
|
- [ read, tie, weak_star_ties ]
|
37
|
+
sphere: organization
|
40
38
|
partner:
|
41
39
|
name: partner
|
42
40
|
parent: member # member is stronger than partner
|
43
41
|
permissions:
|
44
42
|
- [ read, activity, star_ties ]
|
45
|
-
|
46
|
-
name: public
|
47
|
-
parent: partner # partner is stronger than public
|
48
|
-
permissions:
|
49
|
-
- [ read, activity, star_ties ]
|
43
|
+
sphere: organization
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -1,18 +1,7 @@
|
|
1
|
-
|
2
|
-
path = %w( .. .. .. lib generators social_stream templates migration )
|
3
|
-
path.unshift File.dirname(__FILE__)
|
4
|
-
|
5
|
-
require File.join(*path)
|
6
|
-
|
7
|
-
# Use Mailboxer migration template
|
8
|
-
finder = Gem::GemPathSearcher.new
|
9
|
-
mailboxer_spec = finder.find('mailboxer')
|
10
|
-
mailboxer_migration =
|
11
|
-
finder.matching_files(mailboxer_spec,
|
12
|
-
File.join("generators", "mailboxer", "templates", "migration")).first
|
13
|
-
require mailboxer_migration
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', 'support', 'migrations')
|
14
2
|
|
15
3
|
ActiveRecord::Schema.define(:version => 0) do
|
16
4
|
CreateMailboxer.up
|
17
5
|
CreateSocialStream.up
|
6
|
+
ActsAsTaggableOnMigration.up
|
18
7
|
end
|
data/spec/factories/tie.rb
CHANGED
@@ -14,7 +14,7 @@ Factory.define :acquaintance, :parent => :tie do |t|
|
|
14
14
|
end
|
15
15
|
|
16
16
|
Factory.define :public, :parent => :tie do |t|
|
17
|
-
t.after_build { |u| u.relation = u.sender.
|
17
|
+
t.after_build { |u| u.relation = u.sender.relation_public }
|
18
18
|
end
|
19
19
|
|
20
20
|
# Group ties
|
@@ -74,18 +74,32 @@ end
|
|
74
74
|
describe Activity do
|
75
75
|
include ActivityTestHelper
|
76
76
|
|
77
|
-
describe "
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
77
|
+
describe "like" do
|
78
|
+
|
79
|
+
describe "activity" do
|
80
|
+
before do
|
81
|
+
@like_activity = Factory(:like_activity)
|
82
|
+
@activity = @like_activity.parent
|
83
|
+
end
|
82
84
|
|
83
|
-
|
84
|
-
|
85
|
+
it "should recognize the user who likes it" do
|
86
|
+
assert @activity.liked_by?(@like_activity.sender)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should not recognize the user who does not like it" do
|
90
|
+
assert ! @activity.liked_by?(Factory(:user))
|
91
|
+
end
|
85
92
|
end
|
86
93
|
|
87
|
-
|
88
|
-
|
94
|
+
describe "actor" do
|
95
|
+
before do
|
96
|
+
@tie = Factory(:friend)
|
97
|
+
@like = Like.build(@tie.sender, @tie.receiver).save
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should recognize the user who likes it" do
|
101
|
+
assert @tie.receiver.liked_by?(@tie.sender)
|
102
|
+
end
|
89
103
|
end
|
90
104
|
end
|
91
105
|
|
@@ -216,11 +230,11 @@ describe Activity do
|
|
216
230
|
end
|
217
231
|
end
|
218
232
|
|
219
|
-
describe "belonging to public tie" do
|
233
|
+
describe "belonging to public self tie" do
|
220
234
|
|
221
235
|
before do
|
222
236
|
user = Factory(:user)
|
223
|
-
tie = user.ties.where(:relation_id => user.
|
237
|
+
tie = user.ties.where(:relation_id => user.relation_public).first
|
224
238
|
create_activity_assigned_to(tie)
|
225
239
|
end
|
226
240
|
|
@@ -229,10 +243,10 @@ describe Activity do
|
|
229
243
|
create_ability_accessed_by_receiver
|
230
244
|
end
|
231
245
|
|
232
|
-
it_should_behave_like "
|
246
|
+
it_should_behave_like "Allows Creating"
|
233
247
|
it_should_behave_like "Allows Reading"
|
234
|
-
it_should_behave_like "
|
235
|
-
it_should_behave_like "
|
248
|
+
it_should_behave_like "Allows Updating"
|
249
|
+
it_should_behave_like "Allows Destroying"
|
236
250
|
end
|
237
251
|
|
238
252
|
describe "accessed by a friend" do
|
@@ -328,57 +342,4 @@ describe Activity do
|
|
328
342
|
it_should_behave_like "Denies Destroying"
|
329
343
|
end
|
330
344
|
end
|
331
|
-
|
332
|
-
describe "belonging to public tie from a member" do
|
333
|
-
|
334
|
-
before do
|
335
|
-
create_activity_assigned_to(Factory(:member).related('public'))
|
336
|
-
end
|
337
|
-
|
338
|
-
describe "accessed by sender" do
|
339
|
-
before do
|
340
|
-
create_ability_accessed_by_receiver
|
341
|
-
end
|
342
|
-
|
343
|
-
it_should_behave_like "Allows Creating"
|
344
|
-
it_should_behave_like "Allows Reading"
|
345
|
-
it_should_behave_like "Allows Updating"
|
346
|
-
it_should_behave_like "Allows Destroying"
|
347
|
-
end
|
348
|
-
|
349
|
-
describe "accessed by other member" do
|
350
|
-
before do
|
351
|
-
create_ability_accessed_by :member
|
352
|
-
end
|
353
|
-
|
354
|
-
it_should_behave_like "Denies Creating"
|
355
|
-
it_should_behave_like "Allows Reading"
|
356
|
-
it_should_behave_like "Allows Updating"
|
357
|
-
it_should_behave_like "Allows Destroying"
|
358
|
-
end
|
359
|
-
|
360
|
-
|
361
|
-
describe "accessed by partner" do
|
362
|
-
before do
|
363
|
-
create_ability_accessed_by :partner
|
364
|
-
end
|
365
|
-
|
366
|
-
it_should_behave_like "Denies Creating"
|
367
|
-
it_should_behave_like "Allows Reading"
|
368
|
-
it_should_behave_like "Denies Updating"
|
369
|
-
it_should_behave_like "Denies Destroying"
|
370
|
-
end
|
371
|
-
|
372
|
-
describe "accessed publicly" do
|
373
|
-
before do
|
374
|
-
create_ability_accessed_publicly
|
375
|
-
end
|
376
|
-
|
377
|
-
it_should_behave_like "Denies Creating"
|
378
|
-
it_should_behave_like "Allows Reading"
|
379
|
-
it_should_behave_like "Denies Updating"
|
380
|
-
it_should_behave_like "Denies Destroying"
|
381
|
-
end
|
382
|
-
end
|
383
|
-
|
384
345
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe Profile do
|
4
|
+
context "belonging to a user" do
|
5
|
+
before do
|
6
|
+
@profile = Factory(:user).profile
|
7
|
+
end
|
8
|
+
|
9
|
+
context "accessed by her" do
|
10
|
+
before do
|
11
|
+
@ability = Ability.new(@profile.subject)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should allow read" do
|
15
|
+
@ability.should be_able_to(:read, @profile)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should allow update" do
|
19
|
+
@ability.should be_able_to(:update, @profile)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "accessed by other" do
|
24
|
+
before do
|
25
|
+
@ability = Ability.new(Factory(:user))
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should allow read" do
|
29
|
+
@ability.should be_able_to(:read, @profile)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should deny update" do
|
33
|
+
@ability.should_not be_able_to(:update, @profile)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -1,49 +1,106 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
3
|
describe TieActivity do
|
4
|
-
describe "
|
5
|
-
|
6
|
-
@tie = Factory(:friend)
|
7
|
-
|
8
|
-
@tie_to_sender_friend = Factory(:friend, :receiver => @tie.sender)
|
9
|
-
@tie_to_receiver_friend = Factory(:friend, :receiver => @tie.receiver)
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "of a public activity" do
|
4
|
+
describe "dissemination" do
|
5
|
+
context "a friend b" do
|
13
6
|
before do
|
14
|
-
@
|
7
|
+
@afb = Factory(:friend)
|
15
8
|
end
|
16
9
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
10
|
+
context "c friend a" do
|
11
|
+
before do
|
12
|
+
@cfa = Factory(:friend, :receiver => @afb.sender)
|
13
|
+
@a = Factory(:activity, :_tie => @afb)
|
14
|
+
end
|
22
15
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
16
|
+
it "should not be created" do
|
17
|
+
@cfa.activities.should_not include(@a)
|
18
|
+
end
|
19
|
+
|
20
|
+
context "and a friend c" do
|
21
|
+
before do
|
22
|
+
@afc = Factory(:friend, :sender => @cfa.receiver, :receiver => @cfa.sender)
|
23
|
+
@a = Factory(:activity, :_tie => @afb)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should be created" do
|
27
|
+
@cfa.activities.should include(@a)
|
28
|
+
end
|
27
29
|
|
28
|
-
|
29
|
-
assert !@tie_to_sender_friend.activities.include?(@a)
|
30
|
-
assert !@tie_to_receiver_friend.activities.include?(@a)
|
30
|
+
end
|
31
31
|
end
|
32
|
-
end
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
context "and d friend b" do
|
34
|
+
before do
|
35
|
+
@dfb = Factory(:friend, :receiver => @afb.receiver)
|
36
|
+
@a = Factory(:activity, :_tie => @afb)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should not be created" do
|
40
|
+
@dfb.activities.should_not include(@a)
|
41
|
+
end
|
42
|
+
|
43
|
+
context "and b friend d" do
|
44
|
+
before do
|
45
|
+
@bfd = Factory(:friend, :sender => @dfb.receiver, :receiver => @dfb.sender)
|
46
|
+
@a = Factory(:activity, :_tie => @afb)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should not be created" do
|
50
|
+
@dfb.activities.should_not include(@a)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
37
54
|
end
|
38
55
|
|
39
|
-
|
56
|
+
context "and b friend a" do
|
40
57
|
before do
|
41
|
-
@
|
58
|
+
@bfa = Factory(:friend, :sender => @afb.receiver, :receiver => @afb.sender)
|
59
|
+
end
|
60
|
+
|
61
|
+
context "c friend a" do
|
62
|
+
before do
|
63
|
+
@cfa = Factory(:friend, :receiver => @afb.sender)
|
64
|
+
@a = Factory(:activity, :_tie => @afb)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should not be created" do
|
68
|
+
@cfa.activities.should_not include(@a)
|
69
|
+
end
|
70
|
+
|
71
|
+
context "and a friend c" do
|
72
|
+
before do
|
73
|
+
@afc = Factory(:friend, :sender => @cfa.receiver, :receiver => @cfa.sender)
|
74
|
+
@a = Factory(:activity, :_tie => @afb)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should be created" do
|
78
|
+
@cfa.activities.should include(@a)
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
42
82
|
end
|
43
83
|
|
44
|
-
|
45
|
-
|
46
|
-
|
84
|
+
context "and d friend b" do
|
85
|
+
before do
|
86
|
+
@dfb = Factory(:friend, :receiver => @afb.receiver)
|
87
|
+
@a = Factory(:activity, :_tie => @afb)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should not be created" do
|
91
|
+
@dfb.activities.should_not include(@a)
|
92
|
+
end
|
93
|
+
|
94
|
+
context "and b friend d" do
|
95
|
+
before do
|
96
|
+
@bfd = Factory(:friend, :sender => @dfb.receiver, :receiver => @dfb.sender)
|
97
|
+
@a = Factory(:activity, :_tie => @afb)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should be created" do
|
101
|
+
@dfb.activities.should include(@a)
|
102
|
+
end
|
103
|
+
end
|
47
104
|
end
|
48
105
|
end
|
49
106
|
end
|