social_stream 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,15 @@
1
1
  class PermissionsController < InheritedResources::Base
2
2
  before_filter :authenticate_user!
3
- load_and_authorize_resource
4
3
 
5
4
  respond_to :js
6
5
 
7
6
  actions :index
8
7
 
9
8
  belongs_to :relation
9
+
10
+ def index
11
+ authorize! :read, parent
12
+
13
+ index!
14
+ end
10
15
  end
@@ -5,4 +5,12 @@ class Relation::CustomsController < InheritedResources::Base
5
5
  respond_to :js
6
6
 
7
7
  belongs_to :sphere, :optional => true
8
+
9
+ def index
10
+ # Must authorize index, because Cancan does not filter collection with conditions.
11
+ # See https://github.com/ryanb/cancan/wiki/checking-abilities
12
+ authorize! :read, parent.customs.new
13
+
14
+ index!
15
+ end
8
16
  end
data/app/models/actor.rb CHANGED
@@ -75,11 +75,11 @@ class Actor < ActiveRecord::Base
75
75
  scope :distinct_initials, select('DISTINCT SUBSTR(actors.name,1,1) as initial').order("initial ASC")
76
76
 
77
77
  scope :contacted_to, lambda { |a|
78
- joins(:sent_ties).merge(Tie.received_by(a))
78
+ joins(:sent_ties).merge(Tie.received_by(a).intended)
79
79
  }
80
80
 
81
81
  scope :contacted_from, lambda { |a|
82
- joins(:received_ties).merge(Tie.sent_by(a))
82
+ joins(:received_ties).merge(Tie.sent_by(a).intended)
83
83
  }
84
84
 
85
85
  after_create :create_initial_relations
@@ -250,7 +250,7 @@ class Actor < ActiveRecord::Base
250
250
 
251
251
  # Set of ties sent by this actor received by a
252
252
  def ties_to(a)
253
- sent_ties.received_by(a)
253
+ sent_ties.received_by(a).intended
254
254
  end
255
255
 
256
256
  # Get the first of the ties created to a, or create a new one with the {Relation::Public}
data/app/models/tie.rb CHANGED
@@ -45,6 +45,8 @@
45
45
  # integer, array
46
46
  # replied:: ties having at least another tie in the other way, a tie from a to b
47
47
  # is replied if there is a tie from b to a
48
+ # intended:: ties can be desactivated by subjects when they change their connections.
49
+ # This scope gathers the active ones
48
50
  #
49
51
  class Tie < ActiveRecord::Base
50
52
  # Facilitates relation assigment along with find_relation callback
@@ -107,6 +109,8 @@ class Tie < ActiveRecord::Base
107
109
  joins(:relation).where('relations.type' => 'Relation::Public')
108
110
  }
109
111
 
112
+ scope :intended, where(:intended => true)
113
+
110
114
  validates_presence_of :sender_id, :receiver_id, :relation
111
115
 
112
116
  before_validation :find_or_build_relation
@@ -55,9 +55,14 @@
55
55
  </div>
56
56
  </li>
57
57
  <% end %>
58
- <% end %>
59
- </ul>
60
- </dd>
58
+ </li>
59
+ <% end %>
60
+ <li class="new_sphere"><span class="sphere_name"><%= link_to t('contact.type.new'), spheres_path %></span></li>
61
+
62
+ </ul>
63
+
64
+ </dd>
65
+
61
66
  </div>
62
67
  </div>
63
68
  </div>
@@ -3,13 +3,13 @@
3
3
  <a href="#" class="sf-with-ul" id="btn_menu_config"><%= t('account.one') %><span class="sf-sub-indicator"> »</span></a>
4
4
  <ul>
5
5
  <li>
6
- <%= link_to 'Configurations', '#' %>
6
+ <%= link_to t('account.settings'), edit_user_registration_path %>
7
7
  </li>
8
8
  <li>
9
- <%= link_to 'Notifications', '#' %>
9
+ <%= link_to t('account.notifications'), '#' %>
10
10
  </li>
11
11
  <li class="current">
12
- <%= link_to 'Privacy', spheres_path %>
12
+ <%= link_to t('account.privacy'), spheres_path %>
13
13
  </li>
14
14
  </ul>
15
15
  </li>
@@ -12,13 +12,13 @@
12
12
  <% if current_subject.ties_to(subject).present? %>
13
13
  <li >
14
14
  <%= link_to image_tag("btn/btn_friend.png", :class => "menu_icon") +
15
- t('tie.edit.contact', :type => current_subject.ties_to(subject).map(&:relation_name).join(", ")),
15
+ current_subject.ties_to(subject).map(&:relation_name).join(", "),
16
16
  edit_contact_path(subject.actor_id) %>
17
17
  </li>
18
18
  <% else %>
19
19
  <li >
20
20
  <%= link_to image_tag("btn/btn_friend.png", :class => "menu_icon") +
21
- t('tie.add.contact'),
21
+ t('contact.new.title'),
22
22
  edit_contact_path(subject.actor_id),
23
23
  :id => 'contacts_menu' %>
24
24
  </li>
@@ -6,6 +6,9 @@ en:
6
6
  accept: "Accept"
7
7
  account:
8
8
  one: "Account"
9
+ notifications: "Notifications"
10
+ privacy: "Privacy"
11
+ settings: "Settings"
9
12
  activity:
10
13
  confirm_delete: "Delete activity?"
11
14
  delete: "Delete"
@@ -91,6 +94,8 @@ en:
91
94
  one: "Suggestion"
92
95
  other: "Suggestions"
93
96
  all: "All"
97
+ type:
98
+ new: "New type"
94
99
  copyright: "2010 Copyright - All rights reserved"
95
100
  days: Days
96
101
  delete:
@@ -69,13 +69,13 @@ span.ui-radio-state-checked-hover {
69
69
  }
70
70
 
71
71
 
72
- li.sphere_name {
72
+ li.sphere_name, li.new_sphere {
73
73
  background-color: #1F4A75;
74
74
  padding: 5px;
75
75
  text-align: left;
76
76
  }
77
77
 
78
- span.sphere_name{
78
+ span.sphere_name, span.sphere_name a{
79
79
  color: white;
80
80
  }
81
81
 
@@ -78,7 +78,6 @@ module SocialStream
78
78
  # Privacy
79
79
  can [:create, :read, :update, :destroy], Sphere, :actor_id => subject.try(:actor_id)
80
80
  can [:create, :read, :update, :destroy], Relation::Custom, :sphere => { :actor_id => subject.try(:actor_id) }
81
- can :read, Permission
82
81
  end
83
82
  end
84
83
  end
@@ -1,3 +1,3 @@
1
1
  module SocialStream
2
- VERSION = "0.4.5".freeze
2
+ VERSION = "0.4.6".freeze
3
3
  end
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
32
32
  # Pagination
33
33
  s.add_runtime_dependency('will_paginate', '~> 3.0.pre2')
34
34
  # OAuth client
35
- s.add_runtime_dependency('omniauth','~> 0.2.5')
35
+ s.add_runtime_dependency('omniauth','~> 0.2.6')
36
36
  # OAuth provider
37
37
  s.add_runtime_dependency('oauth-plugin','~> 0.4.0.pre1')
38
38
  # Theme support
@@ -31,8 +31,6 @@ describe PermissionsController do
31
31
  end
32
32
 
33
33
  it "should not render index" do
34
- pending
35
-
36
34
  begin
37
35
  get :index, :relation_id => @relation.id, :format => "js"
38
36
 
@@ -75,11 +75,14 @@ describe Relation::CustomsController do
75
75
  end
76
76
 
77
77
  it "should not render index" do
78
- pending
78
+ begin
79
+ get :index, :sphere_id => @sphere.id, :format => "js"
79
80
 
80
- get :index, :sphere_id => @sphere.id, :format => "js"
81
-
82
- assert false
81
+ # Should not get here
82
+ assert false
83
+ rescue CanCan::AccessDenied
84
+ assigns(:customs).should be_blank
85
+ end
83
86
  end
84
87
 
85
88
  context "a new relation" do
@@ -15,19 +15,6 @@ describe Tie do
15
15
 
16
16
  tie.should_not be_new_record
17
17
  end
18
-
19
- it "should be created from relation_name and permissions" do
20
- pending "Redesign forms"
21
-
22
- tie = Tie.create :sender_id => @sender.actor_id,
23
- :receiver_id => @receiver.actor_id,
24
- :relation_name => "new relation",
25
- :relation_permissions => [ Permission.first.id, Permission.last.id ]
26
-
27
- puts tie.errors
28
- tie.should_not be_new_record
29
- tie.relation.should_not be_new_record
30
- end
31
18
  end
32
19
 
33
20
  describe "follower_count" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_stream
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 5
10
- version: 0.4.5
9
+ - 6
10
+ version: 0.4.6
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-05-31 00:00:00 +02:00
19
+ date: 2011-06-01 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -188,12 +188,12 @@ dependencies:
188
188
  requirements:
189
189
  - - ~>
190
190
  - !ruby/object:Gem::Version
191
- hash: 29
191
+ hash: 27
192
192
  segments:
193
193
  - 0
194
194
  - 2
195
- - 5
196
- version: 0.2.5
195
+ - 6
196
+ version: 0.2.6
197
197
  type: :runtime
198
198
  version_requirements: *id011
199
199
  - !ruby/object:Gem::Dependency