social_stream 0.1.7 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +48 -44
- data/app/controllers/ties_controller.rb +1 -0
- data/app/models/ability.rb +2 -0
- data/app/models/actor.rb +7 -8
- data/app/models/permission.rb +80 -0
- data/app/models/relation.rb +1 -6
- data/app/models/tie.rb +34 -42
- data/app/views/activities/_child.html.erb +1 -2
- data/app/views/activities/_jquery.html.erb +2 -3
- data/app/views/activities/_options.html.erb +1 -1
- data/app/views/activities/_root.html.erb +1 -2
- data/app/views/comments/_new.html.erb +18 -15
- data/app/views/groups/_followers.html.erb +16 -14
- data/app/views/groups/_group.html.erb +1 -1
- data/app/views/groups/_location.html.erb +3 -0
- data/app/views/groups/show.html.erb +2 -2
- data/app/views/home/_contacts.html.erb +2 -2
- data/app/views/home/_groups.html.erb +23 -0
- data/app/views/home/_options.html.erb +0 -6
- data/app/views/home/_right.html.erb +1 -6
- data/app/views/home/index.html.erb +3 -3
- data/app/views/posts/_post.html.erb +1 -1
- data/app/views/ties/_suggestions.html.erb +7 -1
- data/app/views/ties/_tie.html.erb +1 -1
- data/app/views/users/_contacts.html.erb +16 -18
- data/app/views/users/_groups.html.erb +1 -2
- data/app/views/users/_location.html.erb +3 -0
- data/app/views/users/_logo.html.erb +2 -4
- data/app/views/users/_menu.html.erb +3 -26
- data/app/views/users/_middle_show.html.erb +0 -1
- data/app/views/users/_options.html.erb +5 -0
- data/app/views/users/_right_show.html.erb +9 -0
- data/app/views/users/show.html.erb +2 -2
- data/config/locales/en.yml +3 -2
- data/lib/generators/social_stream/templates/public/images/btn/{btn_follower.png → btn_group.png} +0 -0
- data/lib/generators/social_stream/templates/public/images/logos/actor/group.png +0 -0
- data/lib/generators/social_stream/templates/public/images/logos/actor/user.png +0 -0
- data/lib/generators/social_stream/templates/public/images/logos/original/group.png +0 -0
- data/lib/generators/social_stream/templates/public/images/logos/original/user.png +0 -0
- data/lib/generators/social_stream/templates/public/images/logos/profile/group.png +0 -0
- data/lib/generators/social_stream/templates/public/images/logos/profile/user.png +0 -0
- data/lib/generators/social_stream/templates/public/images/logos/tie/group.png +0 -0
- data/lib/generators/social_stream/templates/public/images/logos/tie/user.png +0 -0
- data/lib/generators/social_stream/templates/public/images/{btn/title_background.png → title_background.png} +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/middle.css +1 -1
- data/lib/generators/social_stream/templates/public/stylesheets/right.css +1 -0
- data/lib/generators/social_stream/templates/seeds.yml +20 -20
- data/lib/social_stream/ability.rb +26 -0
- data/lib/social_stream/version.rb +1 -1
- data/lib/tasks/db/populate.rake +25 -6
- data/social_stream.gemspec +2 -1
- data/spec/dummy/db/seeds/social_stream.yml +43 -33
- data/spec/factories/tie.rb +15 -10
- data/spec/models/activity_spec.rb +83 -146
- data/spec/models/tie_spec.rb +113 -0
- metadata +52 -25
- data/spec/dummy/app/models/ability.rb +0 -23
Binary file
|
Binary file
|
File without changes
|
@@ -1,40 +1,33 @@
|
|
1
1
|
# Seed configuration for Social Stream
|
2
2
|
#
|
3
|
-
# Define
|
3
|
+
# Define the relations and permissions supported by your application
|
4
4
|
#
|
5
5
|
relations:
|
6
|
-
# User to User
|
7
6
|
user-friend:
|
8
7
|
sender_type: User
|
9
8
|
receiver_type: User
|
10
9
|
name: friend
|
11
|
-
# Friendship is a reciprocal relation
|
12
10
|
inverse: user-friend
|
13
|
-
# It is set for users by default
|
14
11
|
reflexive: true
|
15
12
|
permissions:
|
16
|
-
- [ create,
|
17
|
-
- [ read,
|
18
|
-
- [ update,
|
19
|
-
- [ destroy,
|
13
|
+
- [ create, activity, inverse_weak_set ]
|
14
|
+
- [ read, activity, inverse_group_set ]
|
15
|
+
- [ update, activity, inverse_weak_set ]
|
16
|
+
- [ destroy, activity, inverse_weak_set ]
|
20
17
|
user-public:
|
21
18
|
sender_type: User
|
22
19
|
receiver_type: User
|
23
20
|
name: public
|
24
|
-
# This relation is weaker than user-friend
|
25
21
|
parent: user-friend
|
26
|
-
# This relation is also reciprocal
|
27
22
|
inverse: user-public
|
28
23
|
permissions:
|
29
|
-
- [ read,
|
24
|
+
- [ read, activity, inverse_group_set ]
|
30
25
|
user-friend-request:
|
31
26
|
sender_type: User
|
32
27
|
receiver_type: User
|
33
28
|
name: friend_request
|
34
|
-
# This relation is the request for user-friend
|
35
29
|
granted: user-friend
|
36
30
|
|
37
|
-
# User to Group
|
38
31
|
user-group-member:
|
39
32
|
sender_type: User
|
40
33
|
receiver_type: Group
|
@@ -44,21 +37,28 @@ relations:
|
|
44
37
|
sender_type: User
|
45
38
|
receiver_type: Group
|
46
39
|
name: follower
|
47
|
-
parent: user-group-member
|
48
40
|
user-group-public:
|
49
41
|
sender_type: User
|
50
42
|
receiver_type: Group
|
51
43
|
name: public
|
52
|
-
parent: user-group-
|
44
|
+
parent: user-group-member
|
45
|
+
inverse: group-user-public
|
53
46
|
|
54
|
-
# Group to User
|
55
47
|
group-user-member:
|
56
48
|
sender_type: Group
|
57
49
|
receiver_type: User
|
58
50
|
name: member
|
59
51
|
inverse: user-group-member
|
60
52
|
permissions:
|
61
|
-
- [ create,
|
62
|
-
- [ read,
|
63
|
-
- [ update,
|
64
|
-
- [ destroy,
|
53
|
+
- [ create, activity, inverse_weak_set ]
|
54
|
+
- [ read, activity, inverse_group_set ]
|
55
|
+
- [ update, activity, inverse_weak_group_set ]
|
56
|
+
- [ destroy, activity, inverse_weak_group_set ]
|
57
|
+
group-user-public:
|
58
|
+
sender_type: Group
|
59
|
+
receiver_type: User
|
60
|
+
name: public
|
61
|
+
parent: group-user-member
|
62
|
+
inverse: user-group-public
|
63
|
+
permissions:
|
64
|
+
- [ read, activity, inverse_group_set ]
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module SocialStream
|
2
|
+
class Ability
|
3
|
+
include CanCan::Ability
|
4
|
+
|
5
|
+
def initialize(user)
|
6
|
+
can :create, Activity do |a|
|
7
|
+
# All ties authors must the user
|
8
|
+
a.tie.sender_subject == user &&
|
9
|
+
a.tie.permission?(user, 'create', 'activity')
|
10
|
+
end
|
11
|
+
|
12
|
+
can :read, Activity do |a|
|
13
|
+
a.tie.relation.name == 'public' ||
|
14
|
+
a.tie.permission?(user, 'read', 'activity')
|
15
|
+
end
|
16
|
+
|
17
|
+
can :update, Activity do |a|
|
18
|
+
a.tie.permission?(user, 'update', 'activity')
|
19
|
+
end
|
20
|
+
|
21
|
+
can :destroy, Activity do |a|
|
22
|
+
a.tie.permission?(user, 'destroy', 'activity')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/tasks/db/populate.rake
CHANGED
@@ -27,7 +27,7 @@ namespace :db do
|
|
27
27
|
# = Users
|
28
28
|
|
29
29
|
# Create demo user if not present
|
30
|
-
if User.find_by_name('
|
30
|
+
if User.find_by_name('demo').blank?
|
31
31
|
User.create! :name => 'demostration',
|
32
32
|
:email => 'demostration@test.com',
|
33
33
|
:password => 'demostration',
|
@@ -62,18 +62,37 @@ namespace :db do
|
|
62
62
|
|
63
63
|
Forgery::Basic.number(:at_most => users.size).times do
|
64
64
|
user = users.delete_at((rand * users.size).to_i)
|
65
|
-
u.
|
66
|
-
|
65
|
+
u.sent_ties.create :receiver => user.actor,
|
66
|
+
:relation => user_relations.random
|
67
67
|
end
|
68
|
+
|
68
69
|
groups = available_groups.dup
|
69
|
-
group_relations = Relation.mode('User', 'Group')
|
70
|
+
group_relations = Relation.mode('User', 'Group').all
|
70
71
|
|
71
72
|
Forgery::Basic.number(:at_most => groups.size).times do
|
72
73
|
group = groups.delete_at((rand * groups.size).to_i)
|
73
|
-
u.
|
74
|
-
|
74
|
+
u.sent_ties.create :receiver => group.actor,
|
75
|
+
:relation => group_relations.random
|
75
76
|
end
|
76
77
|
end
|
78
|
+
|
79
|
+
# = Posts
|
80
|
+
|
81
|
+
Tie.all.each do |t|
|
82
|
+
# Only Post from users
|
83
|
+
next if t.relation.sender_type == "Group"
|
84
|
+
|
85
|
+
updated = Time.at(rand(Time.now))
|
86
|
+
|
87
|
+
p = Post.create :text =>
|
88
|
+
"This post should be for #{ I18n.t('other', :scope => t.relation.name) } of #{ t.receiver.name }.\n#{ Forgery::LoremIpsum.paragraph(:random => true) }",
|
89
|
+
:created_at => Time.at(rand(updated)),
|
90
|
+
:updated_at => updated,
|
91
|
+
:_activity_tie_id => t.id
|
92
|
+
|
93
|
+
p.post_activity.update_attributes(:created_at => p.created_at,
|
94
|
+
:updated_at => p.updated_at)
|
95
|
+
end
|
77
96
|
end
|
78
97
|
end
|
79
98
|
end
|
data/social_stream.gemspec
CHANGED
@@ -16,7 +16,8 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.add_runtime_dependency('paperclip', '~> 2.3.4')
|
17
17
|
s.add_runtime_dependency('jquery-rails', '~> 0.2.5')
|
18
18
|
s.add_runtime_dependency('cancan', '~> 1.4.0')
|
19
|
-
s.
|
19
|
+
s.add_runtime_dependency('will_paginate', '~> 2.3.15')
|
20
|
+
s.add_development_dependency('rails', '~> 3.0.3')
|
20
21
|
s.add_development_dependency('capybara', '~> 0.3.9')
|
21
22
|
s.add_development_dependency('sqlite3-ruby')
|
22
23
|
if RUBY_VERSION < '1.9'
|
@@ -1,54 +1,64 @@
|
|
1
|
+
# Seed configuration for Social Stream
|
2
|
+
#
|
3
|
+
# Define the relations and permissions supported by your application
|
4
|
+
#
|
1
5
|
relations:
|
2
6
|
user-friend:
|
3
7
|
sender_type: User
|
4
8
|
receiver_type: User
|
5
9
|
name: friend
|
6
10
|
inverse: user-friend
|
11
|
+
reflexive: true
|
7
12
|
permissions:
|
8
|
-
- [ create,
|
9
|
-
- [ read,
|
10
|
-
- [ update,
|
11
|
-
- [ destroy,
|
12
|
-
user-fof:
|
13
|
-
sender_type: User
|
14
|
-
receiver_type: User
|
15
|
-
name: friend_of_friend
|
16
|
-
parent: user-friend
|
17
|
-
inverse: user-fof
|
18
|
-
permissions:
|
19
|
-
- [ read, resources, group_set ]
|
13
|
+
- [ create, activity, inverse_weak_set ]
|
14
|
+
- [ read, activity, inverse_group_set ]
|
15
|
+
- [ update, activity, inverse_weak_set ]
|
16
|
+
- [ destroy, activity, inverse_weak_set ]
|
20
17
|
user-public:
|
21
18
|
sender_type: User
|
22
19
|
receiver_type: User
|
23
20
|
name: public
|
24
|
-
parent: user-
|
21
|
+
parent: user-friend
|
25
22
|
inverse: user-public
|
26
23
|
permissions:
|
27
|
-
- [ read,
|
28
|
-
|
29
|
-
user-group-admin:
|
24
|
+
- [ read, activity, inverse_group_set ]
|
25
|
+
user-friend-request:
|
30
26
|
sender_type: User
|
31
|
-
receiver_type:
|
32
|
-
name:
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
- [ update, resources, weak_group_set ]
|
37
|
-
- [ destroy, resources, weak_group_set ]
|
38
|
-
user-group-user:
|
27
|
+
receiver_type: User
|
28
|
+
name: friend_request
|
29
|
+
granted: user-friend
|
30
|
+
|
31
|
+
user-group-member:
|
39
32
|
sender_type: User
|
40
33
|
receiver_type: Group
|
41
|
-
name:
|
42
|
-
|
43
|
-
permissions:
|
44
|
-
- [ create, resources, weak_set ]
|
45
|
-
- [ read, resources, group_set ]
|
46
|
-
- [ update, resources, weak_group_set ]
|
47
|
-
- [ destroy, resources, weak_group_set ]
|
34
|
+
name: member
|
35
|
+
inverse: group-user-member
|
48
36
|
user-group-follower:
|
49
37
|
sender_type: User
|
50
38
|
receiver_type: Group
|
51
39
|
name: follower
|
52
|
-
|
40
|
+
user-group-public:
|
41
|
+
sender_type: User
|
42
|
+
receiver_type: Group
|
43
|
+
name: public
|
44
|
+
parent: user-group-member
|
45
|
+
inverse: group-user-public
|
46
|
+
|
47
|
+
group-user-member:
|
48
|
+
sender_type: Group
|
49
|
+
receiver_type: User
|
50
|
+
name: member
|
51
|
+
inverse: user-group-member
|
52
|
+
permissions:
|
53
|
+
- [ create, activity, inverse_weak_set ]
|
54
|
+
- [ read, activity, inverse_group_set ]
|
55
|
+
- [ update, activity, inverse_weak_group_set ]
|
56
|
+
- [ destroy, activity, inverse_weak_group_set ]
|
57
|
+
group-user-public:
|
58
|
+
sender_type: Group
|
59
|
+
receiver_type: User
|
60
|
+
name: public
|
61
|
+
parent: group-user-member
|
62
|
+
inverse: user-group-public
|
53
63
|
permissions:
|
54
|
-
- [ read,
|
64
|
+
- [ read, activity, inverse_group_set ]
|
data/spec/factories/tie.rb
CHANGED
@@ -6,15 +6,15 @@ end
|
|
6
6
|
|
7
7
|
# UserToUser ties
|
8
8
|
|
9
|
-
Factory.define :
|
9
|
+
Factory.define :friend, :parent => :tie do |t|
|
10
10
|
t.relation { |r| Relation.mode('User', 'User').find_by_name('friend') }
|
11
11
|
end
|
12
12
|
|
13
|
-
Factory.define :
|
14
|
-
t.relation { |r| Relation.mode('User', 'User').find_by_name('
|
13
|
+
Factory.define :friend_request, :parent => :tie do |t|
|
14
|
+
t.relation { |r| Relation.mode('User', 'User').find_by_name('friend_request') }
|
15
15
|
end
|
16
16
|
|
17
|
-
Factory.define :
|
17
|
+
Factory.define :public, :parent => :tie do |t|
|
18
18
|
t.relation { |r| Relation.mode('User', 'User').find_by_name('public') }
|
19
19
|
end
|
20
20
|
|
@@ -24,15 +24,20 @@ Factory.define :u2g_tie, :parent => :tie do |t|
|
|
24
24
|
t.relation { |r| Relation.mode('User', 'Group').strongest }
|
25
25
|
end
|
26
26
|
|
27
|
-
Factory.define :
|
28
|
-
t.relation { |r| Relation.mode('User', 'Group').find_by_name('
|
27
|
+
Factory.define :member, :parent => :u2g_tie do |t|
|
28
|
+
t.relation { |r| Relation.mode('User', 'Group').find_by_name('member') }
|
29
29
|
end
|
30
30
|
|
31
|
-
Factory.define :
|
32
|
-
t.relation { |r| Relation.mode('User', 'Group').find_by_name('
|
31
|
+
Factory.define :follower, :parent => :u2g_tie do |t|
|
32
|
+
t.relation { |r| Relation.mode('User', 'Group').find_by_name('follower') }
|
33
33
|
end
|
34
34
|
|
35
|
-
|
36
|
-
|
35
|
+
# GroupToUser ties
|
36
|
+
Factory.define :g2u_tie, :parent => :tie do |t|
|
37
|
+
t.sender { |r| Factory(:group).actor }
|
38
|
+
t.relation { |r| Relation.mode('Group', 'User').strongest }
|
37
39
|
end
|
38
40
|
|
41
|
+
Factory.define :g2u_member, :parent => :tie do |t|
|
42
|
+
t.relation { |r| Relation.mode('Group', 'User').find_by_name('member') }
|
43
|
+
end
|
@@ -1,17 +1,26 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
3
|
module ActivityTestHelper
|
4
|
-
def create_activity_assigned_to(
|
5
|
-
@tie =
|
6
|
-
@activity = Factory(:activity, :tie =>
|
4
|
+
def create_activity_assigned_to(tie)
|
5
|
+
@tie = tie
|
6
|
+
@activity = Factory(:activity, :tie => tie)
|
7
7
|
end
|
8
8
|
|
9
9
|
def create_ability_accessed_by(tie_type)
|
10
10
|
t = Factory(tie_type, :receiver => @tie.receiver)
|
11
|
-
u = t.
|
11
|
+
u = t.sender_subject
|
12
12
|
@ability = Ability.new(u)
|
13
13
|
end
|
14
14
|
|
15
|
+
def create_ability_accessed_by_sender
|
16
|
+
u = @tie.sender_subject
|
17
|
+
@ability = Ability.new(u)
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_ability_accessed_publicly
|
21
|
+
@ability = Ability.new(Factory(:user))
|
22
|
+
end
|
23
|
+
|
15
24
|
shared_examples_for "Allows Creating" do
|
16
25
|
it "should allow create" do
|
17
26
|
@ability.should be_able_to(:create, @activity)
|
@@ -80,15 +89,14 @@ describe Activity do
|
|
80
89
|
end
|
81
90
|
end
|
82
91
|
|
83
|
-
describe "belonging to friend
|
92
|
+
describe "belonging to friend" do
|
84
93
|
before do
|
85
|
-
create_activity_assigned_to(Factory(:
|
94
|
+
create_activity_assigned_to(Factory(:friend))
|
86
95
|
end
|
87
96
|
|
88
|
-
describe "accessed by
|
97
|
+
describe "accessed by sender" do
|
89
98
|
before do
|
90
|
-
|
91
|
-
@ability = Ability.new(u)
|
99
|
+
create_ability_accessed_by_sender
|
92
100
|
end
|
93
101
|
|
94
102
|
it_should_behave_like "Allows Creating"
|
@@ -99,7 +107,7 @@ describe Activity do
|
|
99
107
|
|
100
108
|
describe "accessed by different friend" do
|
101
109
|
before do
|
102
|
-
create_ability_accessed_by :
|
110
|
+
create_ability_accessed_by :friend
|
103
111
|
end
|
104
112
|
|
105
113
|
it_should_behave_like "Denies Creating"
|
@@ -108,9 +116,9 @@ describe Activity do
|
|
108
116
|
it_should_behave_like "Denies Destroying"
|
109
117
|
end
|
110
118
|
|
111
|
-
describe "accessed by friend
|
119
|
+
describe "accessed by friend request" do
|
112
120
|
before do
|
113
|
-
create_ability_accessed_by :
|
121
|
+
create_ability_accessed_by :friend_request
|
114
122
|
end
|
115
123
|
|
116
124
|
it_should_behave_like "Denies Creating"
|
@@ -121,7 +129,7 @@ describe Activity do
|
|
121
129
|
|
122
130
|
describe "accessed publicly" do
|
123
131
|
before do
|
124
|
-
|
132
|
+
create_ability_accessed_publicly
|
125
133
|
end
|
126
134
|
|
127
135
|
it_should_behave_like "Denies Creating"
|
@@ -131,26 +139,15 @@ describe Activity do
|
|
131
139
|
end
|
132
140
|
end
|
133
141
|
|
134
|
-
describe "belonging to
|
142
|
+
describe "belonging to friend reflexive tie" do
|
135
143
|
before do
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
describe "accessed by a friend" do
|
140
|
-
before do
|
141
|
-
create_ability_accessed_by :friend_tie
|
142
|
-
end
|
143
|
-
|
144
|
-
it_should_behave_like "Denies Creating"
|
145
|
-
it_should_behave_like "Allows Reading"
|
146
|
-
it_should_behave_like "Denies Updating"
|
147
|
-
it_should_behave_like "Denies Destroying"
|
144
|
+
tie = Factory(:user).ties.where(:relation_id => Relation.mode('User', 'User').find_by_name('friend')).first
|
145
|
+
create_activity_assigned_to(tie)
|
148
146
|
end
|
149
147
|
|
150
|
-
describe "accessed by
|
148
|
+
describe "accessed by the sender" do
|
151
149
|
before do
|
152
|
-
|
153
|
-
@ability = Ability.new(u)
|
150
|
+
create_ability_accessed_by_sender
|
154
151
|
end
|
155
152
|
|
156
153
|
it_should_behave_like "Allows Creating"
|
@@ -159,9 +156,9 @@ describe Activity do
|
|
159
156
|
it_should_behave_like "Allows Destroying"
|
160
157
|
end
|
161
158
|
|
162
|
-
describe "accessed by
|
159
|
+
describe "accessed by a friend" do
|
163
160
|
before do
|
164
|
-
create_ability_accessed_by :
|
161
|
+
create_ability_accessed_by :friend
|
165
162
|
end
|
166
163
|
|
167
164
|
it_should_behave_like "Denies Creating"
|
@@ -170,9 +167,9 @@ describe Activity do
|
|
170
167
|
it_should_behave_like "Denies Destroying"
|
171
168
|
end
|
172
169
|
|
173
|
-
describe "accessed
|
170
|
+
describe "accessed by friend request" do
|
174
171
|
before do
|
175
|
-
create_ability_accessed_by :
|
172
|
+
create_ability_accessed_by :friend_request
|
176
173
|
end
|
177
174
|
|
178
175
|
it_should_behave_like "Denies Creating"
|
@@ -180,38 +177,40 @@ describe Activity do
|
|
180
177
|
it_should_behave_like "Denies Updating"
|
181
178
|
it_should_behave_like "Denies Destroying"
|
182
179
|
end
|
183
|
-
end
|
184
180
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
181
|
+
describe "accessed publicly" do
|
182
|
+
before do
|
183
|
+
create_ability_accessed_publicly
|
184
|
+
end
|
185
|
+
|
186
|
+
it_should_behave_like "Denies Creating"
|
187
|
+
it_should_behave_like "Denies Reading"
|
188
|
+
it_should_behave_like "Denies Updating"
|
189
|
+
it_should_behave_like "Denies Destroying"
|
190
190
|
end
|
191
|
-
|
192
|
-
it_should_behave_like "Denies Creating"
|
193
191
|
end
|
194
192
|
|
195
|
-
|
196
193
|
describe "belonging to public tie" do
|
194
|
+
|
197
195
|
before do
|
198
|
-
|
196
|
+
tie = Factory(:user).ties.where(:relation_id => Relation.mode('User', 'User').find_by_name('public')).first
|
197
|
+
create_activity_assigned_to(tie)
|
199
198
|
end
|
200
|
-
|
201
|
-
describe "accessed by
|
199
|
+
|
200
|
+
describe "accessed by the sender" do
|
202
201
|
before do
|
203
|
-
|
202
|
+
create_ability_accessed_by_sender
|
204
203
|
end
|
205
204
|
|
206
|
-
it_should_behave_like "
|
205
|
+
it_should_behave_like "Allows Creating"
|
207
206
|
it_should_behave_like "Allows Reading"
|
208
|
-
it_should_behave_like "
|
209
|
-
it_should_behave_like "
|
207
|
+
it_should_behave_like "Allows Updating"
|
208
|
+
it_should_behave_like "Allows Destroying"
|
210
209
|
end
|
211
|
-
|
212
|
-
describe "accessed by
|
210
|
+
|
211
|
+
describe "accessed by a friend" do
|
213
212
|
before do
|
214
|
-
create_ability_accessed_by :
|
213
|
+
create_ability_accessed_by :friend
|
215
214
|
end
|
216
215
|
|
217
216
|
it_should_behave_like "Denies Creating"
|
@@ -220,21 +219,20 @@ describe Activity do
|
|
220
219
|
it_should_behave_like "Denies Destroying"
|
221
220
|
end
|
222
221
|
|
223
|
-
describe "accessed by
|
222
|
+
describe "accessed by friend request" do
|
224
223
|
before do
|
225
|
-
|
226
|
-
@ability = Ability.new(u)
|
224
|
+
create_ability_accessed_by :friend_request
|
227
225
|
end
|
228
226
|
|
229
|
-
it_should_behave_like "
|
227
|
+
it_should_behave_like "Denies Creating"
|
230
228
|
it_should_behave_like "Allows Reading"
|
231
|
-
it_should_behave_like "
|
232
|
-
it_should_behave_like "
|
229
|
+
it_should_behave_like "Denies Updating"
|
230
|
+
it_should_behave_like "Denies Destroying"
|
233
231
|
end
|
234
232
|
|
235
|
-
describe "accessed
|
233
|
+
describe "accessed publicly" do
|
236
234
|
before do
|
237
|
-
|
235
|
+
create_ability_accessed_publicly
|
238
236
|
end
|
239
237
|
|
240
238
|
it_should_behave_like "Denies Creating"
|
@@ -245,24 +243,23 @@ describe Activity do
|
|
245
243
|
end
|
246
244
|
|
247
245
|
describe "belonging to public tie from a public" do
|
246
|
+
|
248
247
|
before do
|
249
|
-
create_activity_assigned_to(Factory(:
|
250
|
-
|
251
|
-
@ability = Ability.new(u)
|
248
|
+
create_activity_assigned_to(Factory(:public))
|
249
|
+
create_ability_accessed_by_sender
|
252
250
|
end
|
253
251
|
|
254
252
|
it_should_behave_like "Denies Creating"
|
255
253
|
end
|
256
254
|
|
257
|
-
describe "belonging to
|
255
|
+
describe "belonging to member tie" do
|
258
256
|
before do
|
259
|
-
create_activity_assigned_to(Factory(:
|
257
|
+
create_activity_assigned_to(Factory(:member))
|
260
258
|
end
|
261
259
|
|
262
|
-
describe "accessed by same
|
260
|
+
describe "accessed by same member" do
|
263
261
|
before do
|
264
|
-
|
265
|
-
@ability = Ability.new(u)
|
262
|
+
create_ability_accessed_by_sender
|
266
263
|
end
|
267
264
|
|
268
265
|
it_should_behave_like "Allows Creating"
|
@@ -271,9 +268,9 @@ describe Activity do
|
|
271
268
|
it_should_behave_like "Allows Destroying"
|
272
269
|
end
|
273
270
|
|
274
|
-
describe "accessed by different
|
271
|
+
describe "accessed by different member" do
|
275
272
|
before do
|
276
|
-
create_ability_accessed_by :
|
273
|
+
create_ability_accessed_by :member
|
277
274
|
end
|
278
275
|
|
279
276
|
it_should_behave_like "Denies Creating"
|
@@ -282,9 +279,9 @@ describe Activity do
|
|
282
279
|
it_should_behave_like "Allows Destroying"
|
283
280
|
end
|
284
281
|
|
285
|
-
describe "accessed by
|
282
|
+
describe "accessed by follower" do
|
286
283
|
before do
|
287
|
-
create_ability_accessed_by :
|
284
|
+
create_ability_accessed_by :follower
|
288
285
|
end
|
289
286
|
|
290
287
|
it_should_behave_like "Denies Creating"
|
@@ -293,9 +290,9 @@ describe Activity do
|
|
293
290
|
it_should_behave_like "Denies Destroying"
|
294
291
|
end
|
295
292
|
|
296
|
-
describe "accessed
|
293
|
+
describe "accessed publicly" do
|
297
294
|
before do
|
298
|
-
|
295
|
+
create_ability_accessed_publicly
|
299
296
|
end
|
300
297
|
|
301
298
|
it_should_behave_like "Denies Creating"
|
@@ -305,26 +302,15 @@ describe Activity do
|
|
305
302
|
end
|
306
303
|
end
|
307
304
|
|
308
|
-
describe "belonging to
|
309
|
-
before do
|
310
|
-
create_activity_assigned_to(Factory(:admin_tie).related('user'))
|
311
|
-
end
|
312
|
-
|
313
|
-
describe "accessed by a admin" do
|
314
|
-
before do
|
315
|
-
create_ability_accessed_by :admin_tie
|
316
|
-
end
|
305
|
+
describe "belonging to public tie from an admin" do
|
317
306
|
|
318
|
-
|
319
|
-
|
320
|
-
it_should_behave_like "Allows Updating"
|
321
|
-
it_should_behave_like "Allows Destroying"
|
307
|
+
before do
|
308
|
+
create_activity_assigned_to(Factory(:member).related('public'))
|
322
309
|
end
|
323
310
|
|
324
|
-
describe "accessed by
|
311
|
+
describe "accessed by sender" do
|
325
312
|
before do
|
326
|
-
|
327
|
-
@ability = Ability.new(u)
|
313
|
+
create_ability_accessed_by_sender
|
328
314
|
end
|
329
315
|
|
330
316
|
it_should_behave_like "Allows Creating"
|
@@ -333,9 +319,9 @@ describe Activity do
|
|
333
319
|
it_should_behave_like "Allows Destroying"
|
334
320
|
end
|
335
321
|
|
336
|
-
describe "accessed by
|
322
|
+
describe "accessed by other member" do
|
337
323
|
before do
|
338
|
-
create_ability_accessed_by :
|
324
|
+
create_ability_accessed_by :member
|
339
325
|
end
|
340
326
|
|
341
327
|
it_should_behave_like "Denies Creating"
|
@@ -344,60 +330,21 @@ describe Activity do
|
|
344
330
|
it_should_behave_like "Allows Destroying"
|
345
331
|
end
|
346
332
|
|
333
|
+
|
347
334
|
describe "accessed by follower" do
|
348
335
|
before do
|
349
|
-
create_ability_accessed_by :
|
336
|
+
create_ability_accessed_by :follower
|
350
337
|
end
|
351
338
|
|
352
339
|
it_should_behave_like "Denies Creating"
|
353
|
-
it_should_behave_like "
|
340
|
+
it_should_behave_like "Allows Reading"
|
354
341
|
it_should_behave_like "Denies Updating"
|
355
342
|
it_should_behave_like "Denies Destroying"
|
356
343
|
end
|
357
|
-
end
|
358
|
-
|
359
|
-
describe "belonging to follower tie" do
|
360
|
-
before do
|
361
|
-
create_activity_assigned_to(Factory(:user_tie).related('follower'))
|
362
|
-
end
|
363
|
-
|
364
|
-
describe "accessed by an admin" do
|
365
|
-
before do
|
366
|
-
create_ability_accessed_by :admin_tie
|
367
|
-
end
|
368
|
-
|
369
|
-
it_should_behave_like "Denies Creating"
|
370
|
-
it_should_behave_like "Allows Reading"
|
371
|
-
it_should_behave_like "Allows Updating"
|
372
|
-
it_should_behave_like "Allows Destroying"
|
373
|
-
end
|
374
344
|
|
375
|
-
describe "accessed
|
376
|
-
before do
|
377
|
-
create_ability_accessed_by :user_tie
|
378
|
-
end
|
379
|
-
|
380
|
-
it_should_behave_like "Denies Creating"
|
381
|
-
it_should_behave_like "Allows Reading"
|
382
|
-
it_should_behave_like "Allows Updating"
|
383
|
-
it_should_behave_like "Allows Destroying"
|
384
|
-
end
|
385
|
-
|
386
|
-
describe "accessed by same sender" do
|
387
|
-
before do
|
388
|
-
u = @tie.sender.subject
|
389
|
-
@ability = Ability.new(u)
|
390
|
-
end
|
391
|
-
|
392
|
-
it_should_behave_like "Allows Creating"
|
393
|
-
it_should_behave_like "Allows Reading"
|
394
|
-
it_should_behave_like "Allows Updating"
|
395
|
-
it_should_behave_like "Allows Destroying"
|
396
|
-
end
|
397
|
-
|
398
|
-
describe "accessed by different follower" do
|
345
|
+
describe "accessed publicly" do
|
399
346
|
before do
|
400
|
-
|
347
|
+
create_ability_accessed_publicly
|
401
348
|
end
|
402
349
|
|
403
350
|
it_should_behave_like "Denies Creating"
|
@@ -407,14 +354,4 @@ describe Activity do
|
|
407
354
|
end
|
408
355
|
end
|
409
356
|
|
410
|
-
describe "belonging to follower tie from a follower" do
|
411
|
-
before do
|
412
|
-
create_activity_assigned_to(Factory(:follower_tie))
|
413
|
-
u = @tie.sender.subject
|
414
|
-
@ability = Ability.new(u)
|
415
|
-
end
|
416
|
-
|
417
|
-
it_should_behave_like "Denies Creating"
|
418
|
-
end
|
419
|
-
|
420
357
|
end
|