social_stream-base 0.6.1 → 0.6.2

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.
Files changed (39) hide show
  1. data/app/assets/javascripts/menu.js +2 -2
  2. data/app/assets/stylesheets/menu.css +8 -9
  3. data/app/controllers/groups_controller.rb +13 -0
  4. data/app/controllers/invitations_controller.rb +26 -12
  5. data/app/helpers/activities_helper.rb +17 -9
  6. data/app/helpers/toolbar_helper.rb +68 -7
  7. data/app/mailers/invitation_mailer.rb +2 -0
  8. data/app/models/actor.rb +4 -0
  9. data/app/models/comment.rb +5 -0
  10. data/app/models/contact.rb +2 -2
  11. data/app/views/comments/_new.html.erb +0 -3
  12. data/app/views/home/index.html.erb +3 -2
  13. data/app/views/invitation_mailer/send_invitation.text.erb +1 -1
  14. data/app/views/invitations/_new.html.erb +1 -3
  15. data/app/views/invitations/new.js.erb +4 -0
  16. data/app/views/toolbar/_home.html.erb +13 -2
  17. data/app/views/toolbar/_profile.html.erb +26 -5
  18. data/db/migrate/20110705103202_empty_ties_count.rb +13 -0
  19. data/lib/generators/social_stream/base/templates/initializer.rb +4 -2
  20. data/lib/social_stream/ability.rb +17 -1
  21. data/lib/social_stream/base/version.rb +1 -1
  22. data/lib/social_stream/models/object.rb +4 -0
  23. data/spec/controllers/comments_controller_spec.rb +9 -6
  24. data/spec/controllers/contacts_controller_spec.rb +22 -0
  25. data/spec/controllers/groups_controller_spec.rb +1 -1
  26. data/spec/dummy/config/initializers/social_stream.rb +4 -2
  27. data/spec/models/contact_spec.rb +11 -0
  28. data/spec/spec_helper.rb +3 -3
  29. data/spec/support/db.rb +1 -2
  30. data/spec/support/migrations.rb +0 -4
  31. metadata +6 -12
  32. data/app/views/toolbar/_home_menu.html.erb +0 -13
  33. data/app/views/toolbar/_home_menu_options.html.erb +0 -41
  34. data/app/views/toolbar/_home_menu_options_subjects.html.erb +0 -12
  35. data/app/views/toolbar/_invitations_menu.html.erb +0 -3
  36. data/app/views/toolbar/_message_menu.html.erb +0 -17
  37. data/app/views/toolbar/_notifications_menu.html.erb +0 -3
  38. data/app/views/toolbar/_profile_menu.html.erb +0 -15
  39. data/spec/dummy/db/migrate/.gitkeep +0 -0
@@ -1,6 +1,6 @@
1
1
  function initMenu() {
2
- $('.menu ul').hide();
3
- $('.menu li a').click( function() {
2
+ $('.toolbar_menu ul li ul').hide();
3
+ $('.toolbar_menu li a').click( function() {
4
4
  $(this).next().slideToggle('normal');
5
5
  }
6
6
  );
@@ -1,14 +1,13 @@
1
1
  /**************MENU***********/
2
- ul.menu {list-style-type:none; margin: 0; padding: 0; width: 15em; border-bottom: thin solid #D4E4EA; }
3
- ul.menu ul {list-style-type:none; margin: 0; padding: 0; width: 15em; }
4
- ul.menu a { display: block; text-decoration: none; }
5
- ul.menu li { border-top: thin solid #D4E4EA; padding-left:0px; }
6
- ul.menu li a, ul.menu ul.menu li a { background: #fff; color: #2A3890; padding: 0.3em; padding:5px 0px 5px 0px; }
7
- ul.menu li a:hover, ul.menu ul.menu li a:hover { background: #DEEFF8; color: #2A3890; text-decoration:none; }
8
- ul.menu li ul li a, ul.menu ul.menu li ul li a { background: #fff; border-left: 5px #2A3890 solid;
2
+ .toolbar_menu {list-style-type:none; margin: 0; padding: 0; width: 15em; border-bottom: thin solid #D4E4EA; }
3
+ .toolbar_menu ul {list-style-type:none; margin: 0; padding: 0; width: 15em; }
4
+ .toolbar_menu a { display: block; text-decoration: none; }
5
+ .toolbar_menu li { border-top: thin solid #D4E4EA; padding-left:0px; }
6
+ .toolbar_menu li a, ul.menu ul.menu li a { background: #fff; color: #2A3890; padding: 0.3em; padding:5px 0px 5px 0px; }
7
+ .toolbar_menu li a:hover, ul.menu ul.menu li a:hover { background: #DEEFF8; color: #2A3890; text-decoration:none; }
8
+ .toolbar_menu li ul li a, ul.menu ul.menu li ul li a { background: #fff; border-left: 5px #2A3890 solid;
9
9
  color: #2A3890; padding-left: 10px;}
10
- ul.menu li ul li a:hover { background: #DEEFF8; border-left: 5px #2A3890 solid; padding-left: 15px;}
11
-
10
+ .toolbar_menu li ul li a:hover { background: #DEEFF8; border-left: 5px #2A3890 solid; padding-left: 15px;}
12
11
 
13
12
  /*
14
13
  div.panel { border: 1px #2A3890 solid; padding: 5px; margin-top: 0px;}
@@ -1,4 +1,8 @@
1
1
  class GroupsController < InheritedResources::Base
2
+ # Set group founder to current_subject
3
+ # Must do before authorization
4
+ before_filter :set_founder, :only => :new
5
+
2
6
  load_and_authorize_resource
3
7
 
4
8
  respond_to :html, :js
@@ -32,4 +36,13 @@ class GroupsController < InheritedResources::Base
32
36
  def resource
33
37
  @group ||= end_of_association_chain.find_by_slug!(params[:id])
34
38
  end
39
+
40
+ private
41
+
42
+ def set_founder
43
+ return unless user_signed_in?
44
+
45
+ params[:group] ||= {}
46
+ params[:group][:_founder] ||= current_subject.slug
47
+ end
35
48
  end
@@ -1,20 +1,34 @@
1
1
  class InvitationsController < ApplicationController
2
-
3
- def new
4
-
2
+ def new
3
+
5
4
  end
6
-
5
+
7
6
  def create
8
-
7
+
9
8
  if params[:mails].present?
10
- receivers = params[:mails].split(",")
11
- receivers.each do |receiver|
12
- InvitationMailer.send_invitation(receiver, current_subject, params[:message]).deliver
9
+ receivers = params[:mails].split(/, */)
10
+ if are_valid_emails?(receivers)
11
+ receivers.each do |receiver|
12
+ InvitationMailer.send_invitation(receiver, current_subject, params[:message]).deliver
13
+ end
14
+ redirect_to new_invitation_path, :flash => { :success => t('invitation.success')}
15
+ return
13
16
  end
14
- redirect_to new_invitation_path, :flash => { :success => t('invitation.success')}
15
- else
16
- redirect_to new_invitation_path, :flash => { :error => t('invitation.error')}
17
17
  end
18
-
18
+ redirect_to new_invitation_path, :flash => { :error => t('invitation.error')}
19
+
19
20
  end
21
+
22
+ private
23
+
24
+ def are_valid_emails?(emails)
25
+ email_regex= /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/
26
+ emails.each do |email|
27
+ if !(email_regex.match(email))
28
+ return false
29
+ end
30
+ end
31
+ return true
32
+ end
33
+
20
34
  end
@@ -1,20 +1,28 @@
1
1
  module ActivitiesHelper
2
-
3
2
  # Link to 'like' or 'unlike' depending on the like status of the activity to current_subject
4
- #
3
+ #
5
4
  # @param [Object]
6
5
  # @return [String]
7
6
  def link_like(object)
7
+ params = link_like_params(object)
8
+ link_to params[0],params[1],params[2]
9
+ end
10
+
11
+ def link_like_params(object)
12
+ params = Array.new
8
13
  if !user_signed_in?
9
- link_to image_tag("btn/nolike.png", :class => "menu_icon")+
10
- t('activity.like'),new_user_session_path
14
+ params << image_tag("btn/nolike.png", :class => "menu_icon")+t('activity.like')
15
+ params << new_user_session_path
16
+ params << {:class => "verb_like",:id => "like_" + dom_id(object)}
11
17
  else
12
18
  if (object.liked_by?(current_subject))
13
- link_to image_tag("btn/like.png", :class => "menu_icon")+
14
- t('activity.unlike'), [object, :like], :method => :delete, :remote => true
19
+ params << image_tag("btn/like.png", :class => "menu_icon")+t('activity.unlike')
20
+ params << [object, :like]
21
+ params << {:class => "verb_like",:id => "like_" + dom_id(object),:method => :delete, :remote => true}
15
22
  else
16
- link_to image_tag("btn/nolike.png", :class => "menu_icon")+
17
- t('activity.like'), [object, :like], :method => :post, :remote => true
23
+ params << image_tag("btn/nolike.png", :class => "menu_icon")+t('activity.like')
24
+ params << [object, :like]
25
+ params << {:class => "verb_like",:id => "like_" + dom_id(object),:method => :post, :remote => true}
18
26
  end
19
27
  end
20
28
  end
@@ -24,6 +32,6 @@ module ActivitiesHelper
24
32
  return Activity.new unless user_signed_in?
25
33
 
26
34
  Activity.new :contact_id => current_subject.contact_to!(receiver).id,
27
- :relation_ids => current_subject.activity_relations(receiver, :from => :receiver).map(&:id)
35
+ :relation_ids => current_subject.activity_relations(receiver, :from => :receiver).map(&:id)
28
36
  end
29
37
  end
@@ -85,21 +85,82 @@ module ToolbarHelper
85
85
  end
86
86
 
87
87
  def default_toolbar_menu
88
- items = [{:key => :notifications,
89
- :name => image_tag("btn/btn_notification.png", :class => "menu_icon")+t('notification.other')+' ('+ current_subject.mailbox.notifications.not_trashed.unread.count.to_s+')',
90
- :url => notifications_path}]
88
+ home_menu
89
+ end
90
+
91
+ def home_toolbar_menu
92
+ items = Array.new
93
+ #Notifications
94
+ items << {:key => :notifications,
95
+ :name => image_tag("btn/btn_notification.png")+t('notification.other')+' ('+ current_subject.mailbox.notifications.not_trashed.unread.count.to_s+')',
96
+ :url => notifications_path,
97
+ :options => {:link => {:id => "notifications_menu"}}}
91
98
 
92
- items << {:key => :dummy1, :name => "Dummy 1", :url => "#", :items => [
93
- {:key => :dummy1_1, :name => "Dummy 1.1", :url => "#"},
94
- {:key => :dummy1_2, :name => "Dummy 1.2", :url => "#"}
99
+ #Messages
100
+ items << {:key => :messages,
101
+ :name => image_tag("btn/new.png")+t('message.other')+' (' + current_subject.mailbox.inbox(:unread => true).count.to_s + ')',
102
+ :url => "#",
103
+ :options => {:link => {:id => "messages_menu"}},
104
+ :items => [
105
+ {:key => :message_new, :name => image_tag("btn/message_new.png")+ t('message.new'), :url => new_message_path},
106
+ {:key => :message_inbox, :name => image_tag("btn/message_inbox.png")+t('message.inbox')+' (' + current_subject.mailbox.inbox(:unread => true).count.to_s + ')',
107
+ :url => conversations_path, :options => {:link =>{:remote=> true}}},
108
+ {:key => :message_sentbox, :name => image_tag("btn/message_sentbox.png")+t('message.sentbox'), :url => conversations_path(:box => :sentbox), :remote=> true},
109
+ {:key => :message_trash, :name => image_tag("btn/message_trash.png")+t('message.trash'), :url => conversations_path(:box => :trash)}
95
110
  ]}
96
111
 
112
+ #Documents if present
113
+ if SocialStream.activity_forms.include? :document
114
+ items << {:key => :resources,
115
+ :name => image_tag("btn/btn_resource.png",:class =>"menu_icon")+t('resource.title'),
116
+ :url => "#",
117
+ :options => {:link => {:id => "resources_menu"}},
118
+ :items => [
119
+ {:key => :resources_documents,:name => image_tag("btn/btn_documents.png")+t('document.title'),:url => documents_path},
120
+ {:key => :resources_pictores,:name => image_tag("btn/btn_gallery.png")+t('picture.title'),:url => pictures_path},
121
+ {:key => :resources_videos,:name => image_tag("btn/btn_video.png")+t('video.title'),:url => videos_path},
122
+ {:key => :resources_audios,:name => image_tag("btn/btn_audio.png")+t('audio.title'),:url => audios_path}
123
+ ]}
124
+ end
125
+
126
+ #Contacts
127
+ relation_items = [{:key => :invitations, :name => image_tag("btn/btn_invitation.png")+t('invitation.other'), :url => new_invitation_path}]
128
+ current_subject.relation_customs.sort.each do |r|
129
+ relation_items << {:key => r.name + "_menu",
130
+ :name => image_tag("btn/btn_friend.png") + r.name,
131
+ :url => contacts_path(:relation => r.id)}
132
+ end
133
+ items << {:key => :contacts,
134
+ :name => image_tag("btn/btn_friend.png")+t('contact.other'),
135
+ :url => "#",
136
+ :options => {:link => {:id => "contacts_menu"}},
137
+ :items => relation_items}
138
+
139
+ #Subjects
140
+ items << {:key => :groups,
141
+ :name => image_tag("btn/btn_group.png")+t('group.other'),
142
+ :url => "#",
143
+ :options => {:link => {:id => "groups_menu"}},
144
+ :items => [{:key => :new_group ,:name => image_tag("btn/btn_group.png")+t('group.new.action'),:url => new_group_path('group' => { '_founder' => current_subject.slug })}]
145
+ }
146
+
147
+ return render_items items
148
+ end
149
+
150
+ def profile_toolbar_menu(subject=current_subject)
151
+ items = Array.new
152
+
153
+ if subject!=current_subject
154
+ items << {:key => :like_button,
155
+ :name => link_like_params(subject)[0],
156
+ :url => link_like_params(subject)[1],
157
+ :options => {:link => link_like_params(subject)[2]}}
158
+ end
97
159
  return render_items items
98
160
  end
99
161
 
100
162
  def render_items(items)
101
163
  menu = render_navigation :items => items
102
- menu = menu.gsub(/\<ul\>/,'<ul class="menu">')
103
164
  return raw menu
104
165
  end
105
166
  end
@@ -1,5 +1,7 @@
1
1
  class InvitationMailer < ActionMailer::Base
2
2
 
3
+
4
+
3
5
  def send_invitation(receiver, sender, message)
4
6
  @sender= sender
5
7
  @message= message
data/app/models/actor.rb CHANGED
@@ -353,7 +353,11 @@ class Actor < ActiveRecord::Base
353
353
  end
354
354
 
355
355
  # Is this {Actor} allowed to create a comment on activity?
356
+ #
357
+ # We are allowing comments from everyone signed in by now
356
358
  def can_comment?(activity)
359
+ return true
360
+
357
361
  comment_relations(activity).any?
358
362
  end
359
363
 
@@ -2,4 +2,9 @@ class Comment < ActiveRecord::Base
2
2
  include SocialStream::Models::Object
3
3
 
4
4
  validates_presence_of :text
5
+
6
+ def _activity_parent_id=(id)
7
+ self._relation_ids = Activity.find(id).relation_ids
8
+ @_activity_parent_id = id
9
+ end
5
10
  end
@@ -126,11 +126,11 @@ class Contact < ActiveRecord::Base
126
126
  end
127
127
  end
128
128
  end
129
-
129
+
130
130
  # Send a message to the contact receiver
131
131
  def send_message
132
132
  if message.present?
133
- sender.send_message(receiver, message, I18n.t("activity.verb.#{ contact_verb }.#{ receiver.subject_type }.message", :name => sender.name))
133
+ sender.send_message(receiver, message, I18n.t("activity.verb.#{ verb }.#{ receiver.subject_type }.message", :name => sender.name))
134
134
  end
135
135
  end
136
136
 
@@ -7,9 +7,6 @@
7
7
  ),
8
8
  :html => { :class => "new_comment", :id => "new_comment"+dom_id(activity) },
9
9
  :remote => true do |f| %>
10
- <% current_subject.comment_relations(activity).each do |r| %>
11
- <%= f.hidden_field "_relation_ids][", :id => "comment__relation_ids_#{ r.id }", :value => r.id %>
12
- <% end %>
13
10
  <%= f.hidden_field :_activity_parent_id %>
14
11
 
15
12
  <%= f.text_field :text, :class =>"input_new_comments" , :id => "comment_text_"+dom_id(activity) %>
@@ -11,8 +11,9 @@
11
11
  <div class="space_center">
12
12
  </div>
13
13
 
14
- <div id="media_wall">
15
- </div>
14
+ <% if SocialStream.activity_forms.include? :document %>
15
+ <%= render :partial => '/documents/mediawall' %>
16
+ <% end %>
16
17
 
17
18
  <% if current_subject.respond_to?(:recent_groups) %>
18
19
  <div id="my_groups">
@@ -1,4 +1,4 @@
1
- <%= @sender.name %> has invited you to <%= link_to( t('socialstream'), new_user_registration_path)%>
1
+ <%= @sender.name %> has invited you to <%= t('socialstream')%>: <%= new_user_registration_path%>
2
2
  "<%= @message%>"
3
3
 
4
4
  <%= t('frontpage.main_title') %>
@@ -4,13 +4,11 @@
4
4
  });
5
5
  <% end %>
6
6
 
7
- <br class="clearfloat" />
8
- <div class="space_center"></div>
9
7
  <div class="space_center"></div>
10
8
 
11
9
  <h2><%=t('invitation.other')%></h2>
12
10
 
13
- <%= form_tag invitations_path, :method=> :post, :class => "invitation_form" do %>
11
+ <%= form_tag invitations_path, :method=> :post, :class => "invitation_form", :remote => true do %>
14
12
  <div class="block">
15
13
  <h3 class= "form_row"><%=t('invitation.join')%></h3>
16
14
  <div class="form_row form_label ">
@@ -0,0 +1,4 @@
1
+ $("#flash").empty();
2
+ $("#flash").append("<%= escape_javascript(render :partial => "layouts/flash", :locals => {:flash => flash})%>");
3
+ $("#content").empty();
4
+ $("#content").append("<%= escape_javascript(render(:partial => 'new'))%>");
@@ -1,9 +1,20 @@
1
- <%= render :partial => 'toolbar/logo', :locals => { :subject => current_subject, } %>
1
+ <% content_for :headers do %>
2
+ <%= stylesheet_link_tag "menu", :media => "screen, projection" %>
3
+ <%= javascript_include_tag 'menu' %>
4
+ <% end %>
5
+
6
+ <%= render :partial => 'toolbar/logo', :locals => {:subject => current_subject} %>
2
7
 
3
8
  <div class="block space_center">
4
9
  </div>
5
10
 
6
- <%= render :partial => 'toolbar/home_menu' %>
11
+ <div id="menu_lateral" class="toolbar_menu">
12
+ Testing SimpleNavigation
13
+ <br>
14
+ Please comment any bug
15
+ <hr>
16
+ <%= yield(:toolbar_menu).empty? ? home_toolbar_menu : yield(:toolbar_menu)%>
17
+ </div>
7
18
 
8
19
  <div class="block space_center">
9
20
  </div>
@@ -1,13 +1,34 @@
1
+ <% content_for :headers do %>
2
+ <%= stylesheet_link_tag "menu", :media => "screen, projection" %>
3
+ <%= javascript_include_tag 'menu' %>
4
+ <% end %>
5
+
1
6
  <%= render :partial => 'toolbar/logo', :locals => { :subject => subject } %>
2
7
 
3
- <div class="block space_center"></div>
8
+ <div class="block space_center">
9
+ </div>
4
10
 
5
- <%= render :partial => 'toolbar/profile_menu', :locals => { :subject => subject } %>
11
+ <div id="menu_lateral" class="toolbar_menu">
12
+ <ul>
13
+ <% unless subject == current_subject %>
14
+ <%= render :partial => "toolbar/profile_menu_tie_options", :locals => { :subject => subject } %>
15
+ <% end %>
6
16
 
7
- <div class="block space_center"></div>
17
+ <%= render :partial => "toolbar/profile_menu_basic_options", :locals => { :subject => subject } %>
18
+ </ul>
19
+ <hr>
20
+ Testing SimpleNavigation
21
+ <br>
22
+ Please move along
23
+ <hr>
24
+ <%= yield(:toolbar_menu).empty? ? profile_toolbar_menu(subject) : yield(:toolbar_menu) %>
25
+ </div>
8
26
 
27
+ <div class="block space_center">
28
+ </div>
9
29
 
10
30
  <%= render :partial => 'subjects/contacts', :locals => { :subject => subject } %>
11
31
 
12
- <div class="block space_center"></div>
13
- <div class="block space_center"></div>
32
+ <div class="block space_center">
33
+ </div>
34
+
@@ -0,0 +1,13 @@
1
+ class EmptyTiesCount < ActiveRecord::Migration
2
+ def up
3
+ change_column :contacts, :ties_count, :integer, :default => 0
4
+
5
+ Contact.record_timestamps = false
6
+ Contact.all.each do |c|
7
+ c.update_attribute(:ties_count, 0) if c.ties_count.nil?
8
+ end
9
+ end
10
+
11
+ def down
12
+ end
13
+ end
@@ -16,6 +16,8 @@ SocialStream.setup do |config|
16
16
  #
17
17
  # config.objects = [ :post, :comment ]
18
18
 
19
- # Form modules to be loaded
20
- # config.activity_forms = [ :document, :other_module, :foo, :bar ]
19
+ # Form for activity objects to be loaded
20
+ # You can write your own activity objects
21
+ #
22
+ # config.activity_forms = [ :post, :document, :foo, :bar ]
21
23
  end
@@ -9,7 +9,7 @@ module SocialStream
9
9
  alias_action :download, :to => :show
10
10
 
11
11
  # Activity Objects
12
- (SocialStream.objects - [ :actor ]).map{ |obj|
12
+ (SocialStream.objects - [ :actor, :comment ]).map{ |obj|
13
13
  obj.to_s.classify.constantize
14
14
  }.each do |klass|
15
15
  can :create, klass do |k| # can :create, Post do |post|
@@ -29,6 +29,22 @@ module SocialStream
29
29
  end
30
30
  end
31
31
 
32
+ can :create, Comment do |c|
33
+ c._activity_parent.allow?(subject, 'read')
34
+ end
35
+
36
+ can :read, Comment do |c|
37
+ c.post_activity.allow?(subject, 'read')
38
+ end
39
+
40
+ can :update, Comment do |c|
41
+ c.post_activity.allow?(subject, 'update')
42
+ end
43
+
44
+ can :destroy, Comment do |c|
45
+ c.post_activity.allow?(subject, 'destroy')
46
+ end
47
+
32
48
  # Activities
33
49
  can :create, Activity do |a|
34
50
  a.allow?(subject, 'create')
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Base
3
- VERSION = "0.6.1".freeze
3
+ VERSION = "0.6.2".freeze
4
4
  end
5
5
  end
@@ -61,6 +61,10 @@ module SocialStream
61
61
  @_contact ||= Contact.find(_contact_id)
62
62
  end
63
63
 
64
+ def _activity_parent
65
+ @_activity_parent ||= Activity.find(_activity_parent_id)
66
+ end
67
+
64
68
  private
65
69
 
66
70
  def create_post_activity
@@ -13,10 +13,11 @@ describe CommentsController do
13
13
 
14
14
  describe "comment from user" do
15
15
  before do
16
+ activity = Factory(:self_activity, :contact => Factory(:self_contact, :sender => @user.actor))
16
17
  contact = @user.contact_to!(@user)
17
- relation = @user.relation_customs.sort.first
18
18
 
19
- model_assigned_to contact, relation
19
+ model_attributes[:_contact_id] = contact.id
20
+ model_attributes[:_activity_parent_id] = activity.id
20
21
  end
21
22
 
22
23
  it_should_behave_like "Allow Creating"
@@ -25,10 +26,11 @@ describe CommentsController do
25
26
  describe "comment to friend" do
26
27
  before do
27
28
  f = Factory(:friend, :contact => Factory(:contact, :receiver => @user.actor)).sender
29
+ activity = Factory(:self_activity, :contact => f.contact_to!(f))
28
30
  contact = @user.contact_to!(f)
29
- relation = f.relation_custom('friend')
30
31
 
31
- model_assigned_to contact, relation
32
+ model_attributes[:_contact_id] = contact.id
33
+ model_attributes[:_activity_parent_id] = activity.id
32
34
  end
33
35
 
34
36
  it_should_behave_like "Allow Creating"
@@ -37,10 +39,11 @@ describe CommentsController do
37
39
  describe "post to acquaintance" do
38
40
  before do
39
41
  a = Factory(:acquaintance, :contact => Factory(:contact, :receiver => @user.actor)).sender
42
+ activity = Factory(:self_activity, :contact => a.contact_to!(a))
40
43
  contact = @user.contact_to!(a)
41
- relation = a.relation_custom('acquaintance')
42
44
 
43
- model_assigned_to contact, relation
45
+ model_attributes[:_contact_id] = contact.id
46
+ model_attributes[:_activity_parent_id] = activity.id
44
47
  end
45
48
 
46
49
  it_should_behave_like "Deny Creating"
@@ -56,4 +56,26 @@ describe ContactsController do
56
56
  should == @user.relations.last
57
57
  end
58
58
 
59
+ it "should create contact with several relations" do
60
+ sign_in @user
61
+
62
+ group = Factory(:group)
63
+ contact = @user.contact_to!(group)
64
+ # Initialize inverse contact
65
+ contact.inverse!
66
+ relations = [ @user.relation_custom('friend'), @user.relation_custom('partner') ]
67
+
68
+
69
+ put :update, :id => contact.id,
70
+ :contact => { :relation_ids => [ "gotcha", relations.map(&:id) ].flatten,
71
+ :message => "Testing" }
72
+
73
+ response.should redirect_to(contact.receiver_subject)
74
+
75
+ contact.reload.
76
+ ties.
77
+ map(&:relation).
78
+ map(&:id).sort.
79
+ should == relations.map(&:id).sort
80
+ end
59
81
  end
@@ -74,7 +74,7 @@ describe GroupsController do
74
74
  end
75
75
 
76
76
  it "should render new" do
77
- get :new, 'group' => { '_founder' => @user.to_param }
77
+ get :new
78
78
 
79
79
  assert_response :success
80
80
  end
@@ -16,6 +16,8 @@ SocialStream.setup do |config|
16
16
  #
17
17
  # config.objects = [ :post, :comment ]
18
18
 
19
- # Form modules to be loaded
20
- # config.activity_forms = [ :document, :other_module, :foo, :bar ]
19
+ # Form for activity objects to be loaded
20
+ # You can write your own activity objects
21
+ #
22
+ # config.activity_forms = [ :post, :document, :foo, :bar ]
21
23
  end
@@ -12,5 +12,16 @@ describe Contact do
12
12
  end
13
13
  end
14
14
 
15
+ context "with message" do
16
+ before do
17
+ @sent = Factory(:contact, :message => 'Hello')
18
+ @received = @sent.inverse!
19
+ end
20
+
21
+ it "should send to the receiver" do
22
+ @sent.message.should == 'Hello'
23
+ @sent.sender_subject.should eq(@received.receiver_subject)
24
+ end
25
+ end
15
26
 
16
27
  end
data/spec/spec_helper.rb CHANGED
@@ -18,12 +18,12 @@ Capybara.default_selector = :css
18
18
  # FIXME orm
19
19
  ActiveRecord::Migration.verbose = false
20
20
 
21
- # Run any available migration
22
- ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
23
-
24
21
  # Load support files
25
22
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
26
23
 
24
+ # Run any available migration
25
+ ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
26
+
27
27
  # Load Factories
28
28
  require 'factory_girl'
29
29
  Dir["#{File.dirname(__FILE__)}/factories/*.rb"].each {|f| require f}
data/spec/support/db.rb CHANGED
@@ -6,7 +6,7 @@ rescue
6
6
  puts "WARNING: ActsAsTaggableOnMigration failed to rollback"
7
7
  end
8
8
 
9
- %w(SocialStream Mailboxer).each do |m|
9
+ %w(Mailboxer).each do |m|
10
10
  begin
11
11
  "Create#{ m }".constantize.down
12
12
  rescue
@@ -15,7 +15,6 @@ end
15
15
  end
16
16
 
17
17
  CreateMailboxer.up
18
- CreateSocialStream.up
19
18
  ActsAsTaggableOnMigration.up
20
19
 
21
20
  require File.expand_path("../../dummy/db/seeds", __FILE__)
@@ -9,10 +9,6 @@ class MigrationFinder
9
9
  end
10
10
  end
11
11
 
12
- # Social Stream Base
13
- MigrationFinder.new 'social_stream-base',
14
- ['..', 'db', 'migrate', '20110610112023_create_social_stream']
15
-
16
12
  # acts-as-taggable-on
17
13
  MigrationFinder.new 'acts-as-taggable-on',
18
14
  ["generators", "acts_as_taggable_on", "migration", "templates", "active_record", "migration"]
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: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 1
10
- version: 0.6.1
9
+ - 2
10
+ version: 0.6.2
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-04 00:00:00 +02:00
19
+ date: 2011-07-06 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -989,6 +989,7 @@ files:
989
989
  - app/views/invitation_mailer/send_invitation.text.erb
990
990
  - app/views/invitations/_new.html.erb
991
991
  - app/views/invitations/new.html.erb
992
+ - app/views/invitations/new.js.erb
992
993
  - app/views/layouts/_account.html.erb
993
994
  - app/views/layouts/_flash.html.erb
994
995
  - app/views/layouts/_footer.html.erb
@@ -1062,15 +1063,8 @@ files:
1062
1063
  - app/views/subjects/_contacts.html.erb
1063
1064
  - app/views/subjects/_tabs.html.erb
1064
1065
  - app/views/toolbar/_home.html.erb
1065
- - app/views/toolbar/_home_menu.html.erb
1066
- - app/views/toolbar/_home_menu_options.html.erb
1067
- - app/views/toolbar/_home_menu_options_subjects.html.erb
1068
- - app/views/toolbar/_invitations_menu.html.erb
1069
1066
  - app/views/toolbar/_logo.html.erb
1070
- - app/views/toolbar/_message_menu.html.erb
1071
- - app/views/toolbar/_notifications_menu.html.erb
1072
1067
  - app/views/toolbar/_profile.html.erb
1073
- - app/views/toolbar/_profile_menu.html.erb
1074
1068
  - app/views/toolbar/_profile_menu_basic_options.html.erb
1075
1069
  - app/views/toolbar/_profile_menu_options.html.erb
1076
1070
  - app/views/toolbar/_profile_menu_tie_options.html.erb
@@ -1087,6 +1081,7 @@ files:
1087
1081
  - config/locales/en.yml
1088
1082
  - config/routes.rb
1089
1083
  - db/migrate/20110610112023_create_social_stream.rb
1084
+ - db/migrate/20110705103202_empty_ties_count.rb
1090
1085
  - lib/acts_as_taggable_on/acts_as_taggable_on/dirty.rb
1091
1086
  - lib/acts_as_taggable_on/social_stream.rb
1092
1087
  - lib/generators/social_stream/base/install_generator.rb
@@ -1149,7 +1144,6 @@ files:
1149
1144
  - spec/dummy/config/navigation.rb
1150
1145
  - spec/dummy/config/relations.yml
1151
1146
  - spec/dummy/config/routes.rb
1152
- - spec/dummy/db/migrate/.gitkeep
1153
1147
  - spec/dummy/db/schema.rb
1154
1148
  - spec/dummy/db/seeds.rb
1155
1149
  - spec/dummy/public/404.html
@@ -1,13 +0,0 @@
1
- <% content_for :headers do %>
2
- <%= stylesheet_link_tag "menu", :media => "screen, projection" %>
3
- <%= javascript_include_tag 'menu' %>
4
- <% end %>
5
-
6
- <div id="menu_lateral">
7
- <%= render :partial => "toolbar/home_menu_options" %>
8
- <hr>
9
- Testing SimpleNavigation<br>Please move along
10
- <hr>
11
- <%= yield(:toolbar_menu).empty? ? default_toolbar_menu : yield(:toolbar_menu)%>
12
- </div>
13
-
@@ -1,41 +0,0 @@
1
- <ul class="menu">
2
-
3
- <%= menu_options[:notifications] || capture do %>
4
- <%= render :partial =>'toolbar/notifications_menu'%>
5
- <% end %>
6
-
7
-
8
- <%= menu_options[:messages] || capture do %>
9
- <%= render :partial =>'toolbar/message_menu'%>
10
- <% end %>
11
-
12
- <%= menu_options[:contacts] || capture do %>
13
- <li>
14
- <%= link_to( image_tag("btn/btn_friend.png", :class => "menu_icon")+t('contact.other'), '#', :id => "contacts_menu") %>
15
- <ul>
16
- <%= menu_options[:invitations] || capture do %>
17
- <%= render :partial =>'toolbar/invitations_menu'%>
18
- <% end %>
19
- <% current_subject.relation_customs.sort.each do |r| %>
20
- <li>
21
- <%= link_to image_tag("btn/btn_friend.png", :class => "menu_icon") + r.name , contacts_path(:relation => r.id) %>
22
- </li>
23
- <% end %>
24
- </ul>
25
- </li>
26
- <% end %>
27
-
28
- <%= menu_options[:subjects] || capture do %>
29
- <%= render :partial => 'toolbar/home_menu_options_subjects' %>
30
- <% end %>
31
-
32
- <% if SocialStream.activity_forms.include? :document %>
33
- <%= menu_options[:uploads] || capture do %>
34
- <%= render :partial =>'toolbar/uploads_menu'%>
35
- <% end %>
36
- <% end %>
37
-
38
-
39
-
40
- </ul>
41
-
@@ -1,12 +0,0 @@
1
- <%= menu_options[:groups] || capture do %>
2
- <li>
3
- <%= link_to( image_tag("btn/btn_group.png", :class => "menu_icon")+t('group.other'), '#', :id => "groups_menu") %>
4
- <ul>
5
- <li>
6
- <%= link_to( image_tag("btn/btn_group.png", :class => "menu_icon")+t('group.new.action'), new_group_path('group' => { '_founder' => current_subject.slug })) %>
7
- </li>
8
- </ul>
9
- </li>
10
-
11
- <% end %>
12
-
@@ -1,3 +0,0 @@
1
- <li>
2
- <%= link_to( image_tag("btn/btn_invitation.png", :class => "menu_icon")+t('invitation.other'), new_invitation_path) %>
3
- </li>
@@ -1,17 +0,0 @@
1
- <li>
2
- <%= link_to( image_tag("btn/new.png", :class => "menu_icon")+t('message.other')+" (" + current_subject.mailbox.inbox(:unread => true).count.to_s + ")", '#', :id => "messages_menu") %>
3
- <ul>
4
- <li>
5
- <%= link_to( image_tag("btn/message_new.png", :class => "menu_icon")+ t('message.new'), new_message_path) %>
6
- </li>
7
- <li>
8
- <%= link_to( image_tag("btn/message_inbox.png", :class => "menu_icon")+t('message.inbox')+" (" + current_subject.mailbox.inbox(:unread => true).count.to_s + ")", conversations_path, :remote => true) %>
9
- </li>
10
- <li>
11
- <%= link_to( image_tag("btn/message_sentbox.png", :class => "menu_icon")+t('message.sentbox'), conversations_path(:box => :sentbox), :remote => true) %>
12
- </li>
13
- <li>
14
- <%= link_to( image_tag("btn/message_trash.png", :class => "menu_icon")+t('message.trash'), conversations_path(:box => :trash), :remote => true) %>
15
- </li>
16
- </ul>
17
- </li>
@@ -1,3 +0,0 @@
1
- <li>
2
- <%= link_to( image_tag("btn/btn_notification.png", :class => "menu_icon")+t('notification.other')+' ('+ current_subject.mailbox.notifications.not_trashed.unread.count.to_s+')', notifications_path) %>
3
- </li>
@@ -1,15 +0,0 @@
1
- <% content_for :headers do %>
2
- <%= stylesheet_link_tag "menu", :media => "screen, projection" %>
3
- <%= javascript_include_tag 'menu' %>
4
- <% end %>
5
-
6
- <div id="menu_lateral">
7
- <ul class="menu">
8
- <% unless subject == current_subject %>
9
- <%= render :partial => "toolbar/profile_menu_tie_options", :locals => { :subject => subject } %>
10
- <% end %>
11
-
12
- <%= render :partial => "toolbar/profile_menu_basic_options", :locals => { :subject => subject } %>
13
- </ul>
14
- </div>
15
- <div class="space_center"></div>
File without changes