social_stream-base 0.6.6 → 0.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
Binary file
@@ -1,15 +1,21 @@
1
1
  module NotificationsHelper
2
- include SubjectsHelper, ActionView::Helpers::TextHelper
2
+ include SubjectsHelper, ActionView::Helpers::TextHelper
3
+
3
4
  def decode_notification notification_text, activity
4
5
  return if activity.nil?
5
- notification_text = notification_text.gsub(/\%\{sender\}/, link_to(truncate_name(activity.sender.name), activity.sender.subject))
6
+ notification_text = notification_text.gsub(/\%\{sender\}/, link_to(truncate_name(activity.sender.name), activity.sender.subject))
7
+ notification_text = notification_text.gsub(/\%\{confirm\}/,link_to(t('notification.confirm'),edit_contact_path(activity.receiver.contact_to!(activity.sender))))
8
+ notification_text = notification_text.gsub(/\%\{look\}/,link_to(t('notification.look'),activity.sender.subject))
6
9
  notification_text = notification_text.gsub(/\%\{sender.name\}/,truncate_name(activity.sender.name))
7
-
10
+
8
11
  if activity.direct_object.present?
9
12
  object = activity.direct_object
10
13
  object = object.subject if object.is_a? Actor
11
14
  notification_text=notification_text.gsub(/\%\{object\}/,link_to(object.class.to_s.downcase,object))
12
15
  notification_text=notification_text.gsub(/\%\{object.name\}/,object.class.to_s.downcase)
16
+ notification_text=notification_text.gsub(/\%\{object.text\}/,link_to(object.text.truncate(100, :separator =>' '), object)) if object.respond_to? :text
17
+ #notification_text=notification_text.gsub(/\%\{object.image\}/,thumb_for(object)) if SocialStream.activity_forms.include? :document and object.is_a? Document
18
+
13
19
  else
14
20
  notification_text=notification_text.gsub(/\%\{object\}/,"nilclass")
15
21
  notification_text=notification_text.gsub(/\%\{object.name\}/,"nilclass")
@@ -79,10 +79,13 @@ class Activity < ActiveRecord::Base
79
79
  order("created_at desc")
80
80
  }
81
81
 
82
+ before_validation :fill_relations
83
+
82
84
  after_create :increment_like_count
83
85
  after_destroy :decrement_like_count, :delete_notifications
84
-
85
86
 
87
+ validates_presence_of :relations
88
+
86
89
  #For now, it should be the last one
87
90
  #FIXME
88
91
  after_create :send_notifications
@@ -222,9 +225,9 @@ class Activity < ActiveRecord::Base
222
225
  if contact.reflexive?
223
226
  return true
224
227
  else
225
- relation_ids = receiver.relation_customs.allow(sender, 'create', 'activity')
226
-
227
- return relation_ids.present?
228
+ receiver.
229
+ relation_customs.allow(sender, 'create', 'activity').
230
+ present?
228
231
  end
229
232
  end
230
233
 
@@ -251,6 +254,16 @@ class Activity < ActiveRecord::Base
251
254
 
252
255
  private
253
256
 
257
+ # Before validation callback
258
+ #
259
+ # Fill the relations when posting to other subject's wall
260
+ def fill_relations
261
+ return if contact.reflexive? || relations.present?
262
+
263
+ self.relations =
264
+ contact.receiver.relation_customs.allow(contact.sender, 'create', 'activity')
265
+ end
266
+
254
267
  #Send notifications to actors based on proximity, interest and permissions
255
268
  def send_notifications
256
269
  notify
data/app/models/actor.rb CHANGED
@@ -143,7 +143,7 @@ class Actor < ActiveRecord::Base
143
143
  receivers = group.contact_actors(:direction => :sent, :relations => relation)
144
144
  emails = Array.new
145
145
  receivers.each do |receiver|
146
- emails << receiver.mailboxer_email
146
+ emails << receiver.email
147
147
  end
148
148
  return emails
149
149
  end
@@ -407,7 +407,8 @@ class Actor < ActiveRecord::Base
407
407
  # Build a new activity where subject like this
408
408
  def new_like(subject)
409
409
  a = Activity.new :verb => "like",
410
- :contact => subject.contact_to!(self)
410
+ :contact => subject.contact_to!(self),
411
+ :relation_ids => Array(subject.relation_public.id)
411
412
 
412
413
  a.activity_objects << activity_object
413
414
 
@@ -1,8 +1,9 @@
1
1
  <div>
2
2
  <div>
3
- <span id="name" style="font-weight: bold;"><%= @sender.name %></span> has invited you to <%= link_to( t('socialstream'), new_user_registration_url)%>
4
- <br/>
5
- <div style="position: absolute;padding: 5px; border: #2A3890 solid 2px; background-color: #E1EEF5; margin:10px; min-height: 125px; width: 500px;">
3
+ <div style="padding: 10px 5px 5px 5px;">
4
+ <span id="name" style="font-weight: bold;"><%= @sender.name %></span> has invited you to <%= link_to( t('socialstream'), new_user_registration_url)%>
5
+ </div>
6
+ <div style="position: static;padding: 5px; border: #2A3890 solid 2px; background-color: #E1EEF5; margin:10px; min-height: 125px; width: 500px;">
6
7
  <div style="float:left; margin-right:7px; border: thin solid #D4E4EA; background-color: white; max-height: 119px;">
7
8
  <img src="http://<%= ActionMailer::Base.default_url_options[:host] +@sender.logo.url(:profile)%>" alt="<%=@sender.name%>">
8
9
  </div>
@@ -20,48 +21,50 @@
20
21
  </div>
21
22
  </div>
22
23
  </div>
23
- <div>
24
- <div>
25
- <%= t('frontpage.share.default')%>:
26
- </div>
27
- <div>
28
- <ul>
29
- <li>
30
- <%= t('frontpage.share.sentence1') %>
31
- </li>
32
- <li>
33
- <%= t('frontpage.share.sentence2') %>
34
- </li>
35
- </ul>
36
- </div>
37
- </div>
38
-
39
- <div>
40
- <div>
41
- <%= t('frontpage.meet.default')%>:
42
- </div>
24
+ <div style="padding: 10px 5px 5px 5px;">
43
25
  <div>
44
- <ul>
45
- <li>
46
- <%= t('frontpage.meet.sentence1') %>
47
- </li>
48
- </ul>
26
+ <div>
27
+ <%= t('frontpage.share.default')%>:
28
+ </div>
29
+ <div>
30
+ <ul>
31
+ <li>
32
+ <%= t('frontpage.share.sentence1') %>
33
+ </li>
34
+ <li>
35
+ <%= t('frontpage.share.sentence2') %>
36
+ </li>
37
+ </ul>
38
+ </div>
49
39
  </div>
50
- </div>
51
-
52
- <div>
40
+
53
41
  <div>
54
- <%= t('frontpage.collaborate.default')%>:
42
+ <div>
43
+ <%= t('frontpage.meet.default')%>:
44
+ </div>
45
+ <div>
46
+ <ul>
47
+ <li>
48
+ <%= t('frontpage.meet.sentence1') %>
49
+ </li>
50
+ </ul>
51
+ </div>
55
52
  </div>
53
+
56
54
  <div>
57
- <ul>
58
- <li>
59
- <%= t('frontpage.collaborate.sentence1') %>
60
- </li>
61
- <li>
62
- <%= t('frontpage.collaborate.sentence2') %>
63
- </li>
64
- </ul>
55
+ <div>
56
+ <%= t('frontpage.collaborate.default')%>:
57
+ </div>
58
+ <div>
59
+ <ul>
60
+ <li>
61
+ <%= t('frontpage.collaborate.sentence1') %>
62
+ </li>
63
+ <li>
64
+ <%= t('frontpage.collaborate.sentence2') %>
65
+ </li>
66
+ </ul>
67
+ </div>
65
68
  </div>
66
69
  </div>
67
70
  </div>
@@ -1,2 +1,2 @@
1
- %{sender} added you as contact.
1
+ %{confirm}
2
2
 
@@ -1,2 +1,2 @@
1
- %{sender.name} added you as contact.
1
+ %{sender} added you as contact.
2
2
 
@@ -1,5 +1,5 @@
1
1
  <% if activity.direct_object.is_a? Actor %>
2
- <%= render :partial => 'notifications/activities/like_subject_body' %>
2
+ %{look}
3
3
  <% else %>
4
- <%= render :partial => 'notifications/activities/like_object_body'%>
5
- <% end %>
4
+ "%{object.text}"
5
+ <% end %>
@@ -1,5 +1,5 @@
1
1
  <% if activity.direct_object.is_a? Actor %>
2
- <%= render :partial => 'notifications/activities/like_subject_subject' %>
2
+ %{sender.name} is now your fan.
3
3
  <% else %>
4
- <%= render :partial => 'notifications/activities/like_object_subject' %>
4
+ %{sender.name} likes your %{object.name}
5
5
  <% end %>
@@ -1,3 +1,2 @@
1
- %{sender} also added you as contact.
2
-
1
+ %{look}
3
2
 
@@ -1,2 +1,2 @@
1
- %{sender.name} added you as contact.
1
+ %{sender} also added you as contact.
2
2
 
@@ -1,2 +1,6 @@
1
- %{sender} added a %{object} in your wall.
2
-
1
+ <% if activity.direct_object.respond_to? :text %>
2
+ "%{object.text}"
3
+ <%end%>
4
+ <% if SocialStream.activity_forms.include? :document and activity.direct_object.is_a? Document %>
5
+ %{object.image}
6
+ <% end%>
@@ -1 +1 @@
1
- %{sender.name} added a %{object.name} in your wall
1
+ %{sender} added a %{object} in your wall
@@ -191,7 +191,9 @@ en:
191
191
  trash: "Trash"
192
192
  send: "Send a message"
193
193
  notification:
194
+ confirm: "Confirm %{sender.name} as contact?"
194
195
  destroy_sure: "Do you want to delete this notification?"
196
+ look: "Take a look at %{sender.name}'s wall"
195
197
  one: "Notification"
196
198
  other: "Notifications"
197
199
  read: "Mark as read"
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Base
3
- VERSION = "0.6.6".freeze
3
+ VERSION = "0.6.8".freeze
4
4
  end
5
5
  end
@@ -42,7 +42,7 @@ module SocialStream
42
42
  :url => "#",
43
43
  :options => {:link => {:id => "contacts_menu"}},
44
44
  :items => [
45
- {:key => :invitations, :name => image_tag("btn/btn_friend.png")+t('contact.addresbook'), :url => contacts_path},
45
+ {:key => :invitations, :name => image_tag("btn/btn_friend.png")+t('contact.addressbook'), :url => contacts_path},
46
46
  {:key => :invitations, :name => image_tag("btn/btn_invitation.png")+t('invitation.toolbar'), :url => new_invitation_path},
47
47
  {:key => :invitations, :name => image_tag("btn/btn_friend.png")+t('contact.pending.other'), :url => contacts_path(:pending=>true)}
48
48
  ]}
@@ -35,7 +35,7 @@ Gem::Specification.new do |s|
35
35
  # OAuth provider
36
36
  s.add_runtime_dependency('oauth-plugin','~> 0.4.0.pre1')
37
37
  # Messages
38
- s.add_runtime_dependency('mailboxer','~> 0.3.2')
38
+ s.add_runtime_dependency('mailboxer','~> 0.3.3')
39
39
  # Avatar manipulation
40
40
  s.add_runtime_dependency('rmagick','~> 2.13.1')
41
41
  # Tagging
@@ -28,6 +28,7 @@ Dummy::Application.configure do
28
28
  # The :test delivery method accumulates sent emails in the
29
29
  # ActionMailer::Base.deliveries array.
30
30
  config.action_mailer.delivery_method = :test
31
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
31
32
 
32
33
  # Use SQL instead of Active Record's schema dumper when creating the test database.
33
34
  # This is necessary if your schema can't be completely dumped by the schema dumper,
@@ -0,0 +1,339 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ module ActivityTestHelper
4
+ def create_activity(contact, relations)
5
+ @activity = Factory(:activity,
6
+ :contact_id => contact.id,
7
+ :relation_ids => Array(Relation.normalize_id(relations)))
8
+
9
+ end
10
+
11
+ def create_ability_accessed_by(subject)
12
+ @ability = Ability.new(subject)
13
+ end
14
+
15
+ def create_ability_accessed_by_related(tie_type)
16
+ @tie = create_related_tie(tie_type)
17
+ @related = @tie.receiver_subject
18
+ @ability = Ability.new(@related)
19
+ end
20
+
21
+ def create_ability_accessed_publicly
22
+ u = Factory(:user)
23
+ @ability = Ability.new(u)
24
+ end
25
+
26
+ def create_related_tie(tie_type)
27
+ Factory(tie_type, :contact => Factory(:contact, :sender => Actor.normalize(@subject)))
28
+ end
29
+
30
+ shared_examples_for "Allows Creating" do
31
+ it "should allow create" do
32
+ @ability.should be_able_to(:create, @activity)
33
+ end
34
+ end
35
+
36
+ shared_examples_for "Allows Reading" do
37
+ it "should allow read" do
38
+ @ability.should be_able_to(:read, @activity)
39
+ end
40
+ end
41
+
42
+ shared_examples_for "Allows Updating" do
43
+ it "should allow update" do
44
+ @ability.should be_able_to(:update, @activity)
45
+ end
46
+ end
47
+
48
+ shared_examples_for "Allows Destroying" do
49
+ it "should allow destroy" do
50
+ @ability.should be_able_to(:destroy, @activity)
51
+ end
52
+ end
53
+
54
+ shared_examples_for "Denies Creating" do
55
+ it "should deny create" do
56
+ @ability.should_not be_able_to(:create, @activity)
57
+ end
58
+ end
59
+
60
+ shared_examples_for "Denies Reading" do
61
+ it "should deny read" do
62
+ @ability.should_not be_able_to(:read, @activity)
63
+ end
64
+ end
65
+
66
+ shared_examples_for "Denies Updating" do
67
+ it "should deny update" do
68
+ @ability.should_not be_able_to(:update, @activity)
69
+ end
70
+ end
71
+
72
+ shared_examples_for "Denies Destroying" do
73
+ it "should deny destroy" do
74
+ @ability.should_not be_able_to(:destroy, @activity)
75
+ end
76
+ end
77
+
78
+ end
79
+
80
+ describe Activity do
81
+ include ActivityTestHelper
82
+
83
+ context "user" do
84
+ before(:all) do
85
+ @subject = @user = Factory(:user)
86
+ end
87
+
88
+ context "with public activity" do
89
+ before do
90
+ contact = @user.contact_to!(@user)
91
+ create_activity(contact, @user.relation_public)
92
+ end
93
+
94
+ describe "sender home" do
95
+ it "should include activity" do
96
+ @activity.sender.wall(:home).should include(@activity)
97
+ end
98
+ end
99
+
100
+ describe "sender profile" do
101
+ context "accessed by alien" do
102
+ it "should include activity" do
103
+ @activity.sender.wall(:profile,
104
+ :for => Factory(:user)).should include(@activity)
105
+ end
106
+ end
107
+
108
+ context "accessed by anonymous" do
109
+ it "should include activity" do
110
+ @activity.sender.wall(:profile,
111
+ :for => nil).should include(@activity)
112
+ end
113
+ end
114
+ end
115
+ end
116
+
117
+ describe "belonging to friend" do
118
+ before do
119
+ @tie = create_related_tie(:friend)
120
+ create_activity(@tie.contact.inverse!, @tie.relation)
121
+ end
122
+
123
+ describe "accessed by sender" do
124
+ before do
125
+ create_ability_accessed_by(@tie.receiver_subject)
126
+ end
127
+
128
+ it_should_behave_like "Allows Creating"
129
+ it_should_behave_like "Allows Reading"
130
+ it_should_behave_like "Allows Updating"
131
+ it_should_behave_like "Allows Destroying"
132
+ end
133
+
134
+ describe "accessed by different friend" do
135
+ before do
136
+ create_ability_accessed_by_related :friend
137
+ end
138
+
139
+ it_should_behave_like "Denies Creating"
140
+ it_should_behave_like "Allows Reading"
141
+ it_should_behave_like "Denies Updating"
142
+ it_should_behave_like "Denies Destroying"
143
+ end
144
+
145
+ describe "accessed by acquaintance" do
146
+ before do
147
+ create_ability_accessed_by_related :acquaintance
148
+ end
149
+
150
+ it_should_behave_like "Denies Creating"
151
+ it_should_behave_like "Denies Reading"
152
+ it_should_behave_like "Denies Updating"
153
+ it_should_behave_like "Denies Destroying"
154
+ end
155
+
156
+ describe "accessed publicly" do
157
+ before do
158
+ create_ability_accessed_publicly
159
+ end
160
+
161
+ it_should_behave_like "Denies Creating"
162
+ it_should_behave_like "Denies Reading"
163
+ it_should_behave_like "Denies Updating"
164
+ it_should_behave_like "Denies Destroying"
165
+ end
166
+ end
167
+
168
+ describe "belonging to user's friend relation" do
169
+ before do
170
+ create_activity(@user.contact_to!(@user), @user.relation_custom('friend'))
171
+ end
172
+
173
+ describe "accessed by the sender" do
174
+ before do
175
+ create_ability_accessed_by(@user)
176
+ end
177
+
178
+ it_should_behave_like "Allows Creating"
179
+ it_should_behave_like "Allows Reading"
180
+ it_should_behave_like "Allows Updating"
181
+ it_should_behave_like "Allows Destroying"
182
+ end
183
+
184
+ describe "accessed by a friend" do
185
+ before do
186
+ create_ability_accessed_by_related :friend
187
+ end
188
+
189
+ it_should_behave_like "Denies Creating"
190
+ it_should_behave_like "Allows Reading"
191
+ it_should_behave_like "Denies Updating"
192
+ it_should_behave_like "Denies Destroying"
193
+ end
194
+
195
+ describe "accessed by acquaintance" do
196
+ before do
197
+ create_ability_accessed_by_related :acquaintance
198
+ end
199
+
200
+ it_should_behave_like "Denies Creating"
201
+ it_should_behave_like "Denies Reading"
202
+ it_should_behave_like "Denies Updating"
203
+ it_should_behave_like "Denies Destroying"
204
+ end
205
+
206
+ describe "accessed publicly" do
207
+ before do
208
+ create_ability_accessed_publicly
209
+ end
210
+
211
+ it_should_behave_like "Denies Creating"
212
+ it_should_behave_like "Denies Reading"
213
+ it_should_behave_like "Denies Updating"
214
+ it_should_behave_like "Denies Destroying"
215
+ end
216
+ end
217
+
218
+ describe "belonging to user's public relation" do
219
+
220
+ before do
221
+ create_activity(@user.contact_to!(@user), @user.relation_public)
222
+ end
223
+
224
+ describe "accessed by the sender" do
225
+ before do
226
+ create_ability_accessed_by(@user)
227
+ end
228
+
229
+ it_should_behave_like "Allows Creating"
230
+ it_should_behave_like "Allows Reading"
231
+ it_should_behave_like "Allows Updating"
232
+ it_should_behave_like "Allows Destroying"
233
+ end
234
+
235
+ describe "accessed by a friend" do
236
+ before do
237
+ create_ability_accessed_by_related :friend
238
+ end
239
+
240
+ it_should_behave_like "Denies Creating"
241
+ it_should_behave_like "Allows Reading"
242
+ it_should_behave_like "Denies Updating"
243
+ it_should_behave_like "Denies Destroying"
244
+ end
245
+
246
+ describe "accessed by acquaintance" do
247
+ before do
248
+ create_ability_accessed_by_related :acquaintance
249
+ end
250
+
251
+ it_should_behave_like "Denies Creating"
252
+ it_should_behave_like "Allows Reading"
253
+ it_should_behave_like "Denies Updating"
254
+ it_should_behave_like "Denies Destroying"
255
+ end
256
+
257
+ describe "accessed publicly" do
258
+ before do
259
+ create_ability_accessed_publicly
260
+ end
261
+
262
+ it_should_behave_like "Denies Creating"
263
+ it_should_behave_like "Allows Reading"
264
+ it_should_behave_like "Denies Updating"
265
+ it_should_behave_like "Denies Destroying"
266
+ end
267
+ end
268
+
269
+ describe "belonging to other user's public relation" do
270
+
271
+ before do
272
+ @tie = Factory(:public)
273
+ create_activity @tie.contact, @tie.sender.relation_public
274
+ create_ability_accessed_by @tie.receiver_subject
275
+ end
276
+
277
+ it_should_behave_like "Denies Creating"
278
+ end
279
+ end
280
+
281
+ context "group" do
282
+ before(:all) do
283
+ @subject = @group = Factory(:group)
284
+ end
285
+
286
+ describe "belonging to member tie" do
287
+ before do
288
+ @tie = create_related_tie(:member)
289
+ create_activity @tie.contact.inverse!, @tie.relation
290
+ end
291
+
292
+ describe "accessed by same member" do
293
+ before do
294
+ create_ability_accessed_by @tie.receiver_subject
295
+ end
296
+
297
+ it_should_behave_like "Allows Creating"
298
+ it_should_behave_like "Allows Reading"
299
+ it_should_behave_like "Allows Updating"
300
+ it_should_behave_like "Allows Destroying"
301
+ end
302
+
303
+ describe "accessed by different member" do
304
+ before do
305
+ create_ability_accessed_by_related :member
306
+ end
307
+
308
+ it_should_behave_like "Denies Creating"
309
+ it_should_behave_like "Allows Reading"
310
+ it_should_behave_like "Denies Updating"
311
+ it_should_behave_like "Denies Destroying"
312
+ end
313
+
314
+ describe "accessed by partner" do
315
+ before do
316
+ create_ability_accessed_by_related :partner
317
+ end
318
+
319
+ it_should_behave_like "Denies Creating"
320
+ it_should_behave_like "Denies Reading"
321
+ it_should_behave_like "Denies Updating"
322
+ it_should_behave_like "Denies Destroying"
323
+ end
324
+
325
+ describe "accessed publicly" do
326
+ before do
327
+ create_ability_accessed_publicly
328
+ end
329
+
330
+ it_should_behave_like "Denies Creating"
331
+ it_should_behave_like "Denies Reading"
332
+ it_should_behave_like "Denies Updating"
333
+ it_should_behave_like "Denies Destroying"
334
+ end
335
+ end
336
+ end
337
+ end
338
+
339
+
@@ -1,84 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
- module ActivityTestHelper
4
- def create_activity(contact, relations)
5
- @activity = Factory(:activity,
6
- :contact_id => contact.id,
7
- :relation_ids => Array(Relation.normalize_id(relations)))
8
-
9
- end
10
-
11
- def create_ability_accessed_by(subject)
12
- @ability = Ability.new(subject)
13
- end
14
-
15
- def create_ability_accessed_by_related(tie_type)
16
- @tie = create_related_tie(tie_type)
17
- @related = @tie.receiver_subject
18
- @ability = Ability.new(@related)
19
- end
20
-
21
- def create_ability_accessed_publicly
22
- u = Factory(:user)
23
- @ability = Ability.new(u)
24
- end
25
-
26
- def create_related_tie(tie_type)
27
- Factory(tie_type, :contact => Factory(:contact, :sender => Actor.normalize(@subject)))
28
- end
29
-
30
- shared_examples_for "Allows Creating" do
31
- it "should allow create" do
32
- @ability.should be_able_to(:create, @activity)
33
- end
34
- end
35
-
36
- shared_examples_for "Allows Reading" do
37
- it "should allow read" do
38
- @ability.should be_able_to(:read, @activity)
39
- end
40
- end
41
-
42
- shared_examples_for "Allows Updating" do
43
- it "should allow update" do
44
- @ability.should be_able_to(:update, @activity)
45
- end
46
- end
47
-
48
- shared_examples_for "Allows Destroying" do
49
- it "should allow destroy" do
50
- @ability.should be_able_to(:destroy, @activity)
51
- end
52
- end
53
-
54
- shared_examples_for "Denies Creating" do
55
- it "should deny create" do
56
- @ability.should_not be_able_to(:create, @activity)
57
- end
58
- end
59
-
60
- shared_examples_for "Denies Reading" do
61
- it "should deny read" do
62
- @ability.should_not be_able_to(:read, @activity)
63
- end
64
- end
65
-
66
- shared_examples_for "Denies Updating" do
67
- it "should deny update" do
68
- @ability.should_not be_able_to(:update, @activity)
69
- end
70
- end
71
-
72
- shared_examples_for "Denies Destroying" do
73
- it "should deny destroy" do
74
- @ability.should_not be_able_to(:destroy, @activity)
75
- end
76
- end
77
-
78
- end
79
-
80
3
  describe Activity do
81
- include ActivityTestHelper
82
4
 
83
5
  describe "wall" do
84
6
  context "with a friend activity" do
@@ -207,261 +129,6 @@ describe Activity do
207
129
  end
208
130
  end
209
131
 
210
- context "user" do
211
- before(:all) do
212
- @subject = @user = Factory(:user)
213
- end
214
-
215
- context "with public activity" do
216
- before do
217
- contact = @user.contact_to!(@user)
218
- create_activity(contact, @user.relation_public)
219
- end
220
-
221
- describe "sender home" do
222
- it "should include activity" do
223
- @activity.sender.wall(:home).should include(@activity)
224
- end
225
- end
226
-
227
- describe "sender profile" do
228
- context "accessed by alien" do
229
- it "should include activity" do
230
- @activity.sender.wall(:profile,
231
- :for => Factory(:user)).should include(@activity)
232
- end
233
- end
234
-
235
- context "accessed by anonymous" do
236
- it "should include activity" do
237
- @activity.sender.wall(:profile,
238
- :for => nil).should include(@activity)
239
- end
240
- end
241
- end
242
- end
243
-
244
- describe "belonging to friend" do
245
- before do
246
- @tie = create_related_tie(:friend)
247
- create_activity(@tie.contact.inverse!, @tie.relation)
248
- end
249
-
250
- describe "accessed by sender" do
251
- before do
252
- create_ability_accessed_by(@tie.receiver_subject)
253
- end
254
-
255
- it_should_behave_like "Allows Creating"
256
- it_should_behave_like "Allows Reading"
257
- it_should_behave_like "Allows Updating"
258
- it_should_behave_like "Allows Destroying"
259
- end
260
-
261
- describe "accessed by different friend" do
262
- before do
263
- create_ability_accessed_by_related :friend
264
- end
265
-
266
- it_should_behave_like "Denies Creating"
267
- it_should_behave_like "Allows Reading"
268
- it_should_behave_like "Denies Updating"
269
- it_should_behave_like "Denies Destroying"
270
- end
271
-
272
- describe "accessed by acquaintance" do
273
- before do
274
- create_ability_accessed_by_related :acquaintance
275
- end
276
-
277
- it_should_behave_like "Denies Creating"
278
- it_should_behave_like "Denies Reading"
279
- it_should_behave_like "Denies Updating"
280
- it_should_behave_like "Denies Destroying"
281
- end
282
-
283
- describe "accessed publicly" do
284
- before do
285
- create_ability_accessed_publicly
286
- end
287
-
288
- it_should_behave_like "Denies Creating"
289
- it_should_behave_like "Denies Reading"
290
- it_should_behave_like "Denies Updating"
291
- it_should_behave_like "Denies Destroying"
292
- end
293
- end
294
-
295
- describe "belonging to user's friend relation" do
296
- before do
297
- create_activity(@user.contact_to!(@user), @user.relation_custom('friend'))
298
- end
299
-
300
- describe "accessed by the sender" do
301
- before do
302
- create_ability_accessed_by(@user)
303
- end
304
-
305
- it_should_behave_like "Allows Creating"
306
- it_should_behave_like "Allows Reading"
307
- it_should_behave_like "Allows Updating"
308
- it_should_behave_like "Allows Destroying"
309
- end
310
-
311
- describe "accessed by a friend" do
312
- before do
313
- create_ability_accessed_by_related :friend
314
- end
315
-
316
- it_should_behave_like "Denies Creating"
317
- it_should_behave_like "Allows Reading"
318
- it_should_behave_like "Denies Updating"
319
- it_should_behave_like "Denies Destroying"
320
- end
321
-
322
- describe "accessed by acquaintance" do
323
- before do
324
- create_ability_accessed_by_related :acquaintance
325
- end
326
-
327
- it_should_behave_like "Denies Creating"
328
- it_should_behave_like "Denies Reading"
329
- it_should_behave_like "Denies Updating"
330
- it_should_behave_like "Denies Destroying"
331
- end
332
-
333
- describe "accessed publicly" do
334
- before do
335
- create_ability_accessed_publicly
336
- end
337
-
338
- it_should_behave_like "Denies Creating"
339
- it_should_behave_like "Denies Reading"
340
- it_should_behave_like "Denies Updating"
341
- it_should_behave_like "Denies Destroying"
342
- end
343
- end
344
-
345
- describe "belonging to user's public relation" do
346
-
347
- before do
348
- create_activity(@user.contact_to!(@user), @user.relation_public)
349
- end
350
-
351
- describe "accessed by the sender" do
352
- before do
353
- create_ability_accessed_by(@user)
354
- end
355
-
356
- it_should_behave_like "Allows Creating"
357
- it_should_behave_like "Allows Reading"
358
- it_should_behave_like "Allows Updating"
359
- it_should_behave_like "Allows Destroying"
360
- end
361
-
362
- describe "accessed by a friend" do
363
- before do
364
- create_ability_accessed_by_related :friend
365
- end
366
-
367
- it_should_behave_like "Denies Creating"
368
- it_should_behave_like "Allows Reading"
369
- it_should_behave_like "Denies Updating"
370
- it_should_behave_like "Denies Destroying"
371
- end
372
-
373
- describe "accessed by acquaintance" do
374
- before do
375
- create_ability_accessed_by_related :acquaintance
376
- end
377
-
378
- it_should_behave_like "Denies Creating"
379
- it_should_behave_like "Allows Reading"
380
- it_should_behave_like "Denies Updating"
381
- it_should_behave_like "Denies Destroying"
382
- end
383
-
384
- describe "accessed publicly" do
385
- before do
386
- create_ability_accessed_publicly
387
- end
388
-
389
- it_should_behave_like "Denies Creating"
390
- it_should_behave_like "Allows Reading"
391
- it_should_behave_like "Denies Updating"
392
- it_should_behave_like "Denies Destroying"
393
- end
394
- end
395
-
396
- describe "belonging to other user's public relation" do
397
-
398
- before do
399
- @tie = Factory(:public)
400
- create_activity @tie.contact, @tie.sender.relation_public
401
- create_ability_accessed_by @tie.receiver_subject
402
- end
403
-
404
- it_should_behave_like "Denies Creating"
405
- end
406
- end
407
-
408
- context "group" do
409
- before(:all) do
410
- @subject = @group = Factory(:group)
411
- end
412
-
413
- describe "belonging to member tie" do
414
- before do
415
- @tie = create_related_tie(:member)
416
- create_activity @tie.contact.inverse!, @tie.relation
417
- end
418
-
419
- describe "accessed by same member" do
420
- before do
421
- create_ability_accessed_by @tie.receiver_subject
422
- end
423
-
424
- it_should_behave_like "Allows Creating"
425
- it_should_behave_like "Allows Reading"
426
- it_should_behave_like "Allows Updating"
427
- it_should_behave_like "Allows Destroying"
428
- end
429
-
430
- describe "accessed by different member" do
431
- before do
432
- create_ability_accessed_by_related :member
433
- end
434
-
435
- it_should_behave_like "Denies Creating"
436
- it_should_behave_like "Allows Reading"
437
- it_should_behave_like "Denies Updating"
438
- it_should_behave_like "Denies Destroying"
439
- end
440
-
441
- describe "accessed by partner" do
442
- before do
443
- create_ability_accessed_by_related :partner
444
- end
445
-
446
- it_should_behave_like "Denies Creating"
447
- it_should_behave_like "Denies Reading"
448
- it_should_behave_like "Denies Updating"
449
- it_should_behave_like "Denies Destroying"
450
- end
451
-
452
- describe "accessed publicly" do
453
- before do
454
- create_ability_accessed_publicly
455
- end
456
-
457
- it_should_behave_like "Denies Creating"
458
- it_should_behave_like "Denies Reading"
459
- it_should_behave_like "Denies Updating"
460
- it_should_behave_like "Denies Destroying"
461
- end
462
- end
463
- end
464
-
465
132
  context "without relations" do
466
133
  it "should allow create to friend" do
467
134
  tie = Factory(:friend)
@@ -470,5 +137,16 @@ describe Activity do
470
137
 
471
138
  assert activity.allow?(tie.receiver, 'create')
472
139
  end
140
+
141
+ it "should fill relation" do
142
+ tie = Factory(:friend)
143
+
144
+ post = Post.new :text => "testing",
145
+ :_contact_id => tie.contact.inverse!.id
146
+
147
+ post.save!
148
+
149
+ post.post_activity.relations.should include(tie.relation)
150
+ end
473
151
  end
474
152
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_stream-base
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 6
10
- version: 0.6.6
9
+ - 8
10
+ version: 0.6.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - GING - DIT - UPM
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-07-13 00:00:00 +02:00
19
+ date: 2011-07-18 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -205,12 +205,12 @@ dependencies:
205
205
  requirements:
206
206
  - - ~>
207
207
  - !ruby/object:Gem::Version
208
- hash: 23
208
+ hash: 21
209
209
  segments:
210
210
  - 0
211
211
  - 3
212
- - 2
213
- version: 0.3.2
212
+ - 3
213
+ version: 0.3.3
214
214
  type: :runtime
215
215
  version_requirements: *id012
216
216
  - !ruby/object:Gem::Dependency
@@ -447,6 +447,7 @@ extra_rdoc_files: []
447
447
  files:
448
448
  - .gitignore
449
449
  - .rspec
450
+ - .travis.yml
450
451
  - .yardopts
451
452
  - Gemfile
452
453
  - LICENSE
@@ -1011,11 +1012,7 @@ files:
1011
1012
  - app/views/notifications/activities/_follow_body.html.erb
1012
1013
  - app/views/notifications/activities/_follow_subject.html.erb
1013
1014
  - app/views/notifications/activities/_like_body.html.erb
1014
- - app/views/notifications/activities/_like_object_body.html.erb
1015
- - app/views/notifications/activities/_like_object_subject.html.erb
1016
1015
  - app/views/notifications/activities/_like_subject.html.erb
1017
- - app/views/notifications/activities/_like_subject_body.html.erb
1018
- - app/views/notifications/activities/_like_subject_subject.html.erb
1019
1016
  - app/views/notifications/activities/_make-friend_body.html.erb
1020
1017
  - app/views/notifications/activities/_make-friend_subject.html.erb
1021
1018
  - app/views/notifications/activities/_post_body.html.erb
@@ -1153,6 +1150,7 @@ files:
1153
1150
  - spec/factories/tie.rb
1154
1151
  - spec/factories/user.rb
1155
1152
  - spec/integration/navigation_spec.rb
1153
+ - spec/models/activity_authorization_spec.rb
1156
1154
  - spec/models/activity_spec.rb
1157
1155
  - spec/models/actor_spec.rb
1158
1156
  - spec/models/contact_spec.rb
@@ -1,2 +0,0 @@
1
- %{sender} likes your %{object}.
2
-
@@ -1,2 +0,0 @@
1
- %{sender.name} likes your %{object.name}
2
-
@@ -1 +0,0 @@
1
- %{sender} is now your fan.
@@ -1,2 +0,0 @@
1
- %{sender.name} is now your fan.
2
-