Skip to content
Extraits de code Groupes Projets
Valider 58d496e1 rédigé par Maxwell Salzberg's avatar Maxwell Salzberg
Parcourir les fichiers

MS SM WIP

parent e1aa709c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -2,7 +2,6 @@ branches: ...@@ -2,7 +2,6 @@ branches:
only: only:
- 'master' - 'master'
rvm: rvm:
- 1.8.7 - 1.8.7
- ree - ree
......
...@@ -168,6 +168,7 @@ Diaspora::Application.routes.draw do ...@@ -168,6 +168,7 @@ Diaspora::Application.routes.draw do
namespace :api do namespace :api do
namespace :v0 do namespace :v0 do
get "/users/:username" => 'users#show', :as => 'user' get "/users/:username" => 'users#show', :as => 'user'
get "/tags/:name" => 'tags#show', :as => 'tag'
end end
end end
......
...@@ -120,7 +120,7 @@ class Stream::Base ...@@ -120,7 +120,7 @@ class Stream::Base
def post_is_from_contact?(post) def post_is_from_contact?(post)
@can_comment_cache ||= {} @can_comment_cache ||= {}
@can_comment_cache[post.id] ||= contacts_in_stream.find{|contact| contact.person_id == post.author.id}.present? @can_comment_cache[post.id] ||= contacts_in_stream.find{|contact| contact.person_id == post.author.id}.present?
@can_comment_cache[post.id] ||= user.person.id == post.author.id @can_comment_cache[post.id] ||= (user.person.id == post.author.id)
@can_comment_cache[post.id] @can_comment_cache[post.id]
end end
end end
...@@ -11,22 +11,22 @@ describe Stream::Base do ...@@ -11,22 +11,22 @@ describe Stream::Base do
@stream.stub(:people).and_return([bob.person, eve.person, @person]) @stream.stub(:people).and_return([bob.person, eve.person, @person])
end end
it 'returns true if user is a contact of the post author' do it 'allows me to comment on my local contacts post' do
post = Factory(:status_message, :author => bob.person) post = Factory(:status_message, :author => bob.person)
@stream.can_comment?(post).should be_true @stream.can_comment?(post).should be_true
end end
it 'returns true if a user is the author of the post' do it 'allows me to comment on my own post' do
post = Factory(:status_message, :author => alice.person) post = Factory(:status_message, :author => alice.person)
@stream.can_comment?(post).should be_true @stream.can_comment?(post).should be_true
end end
it 'returns true if the author of the post is local' do it 'allows me to comment on any local public post' do
post = Factory(:status_message, :author => eve.person) post = Factory(:status_message, :author => eve.person)
@stream.can_comment?(post).should be_true @stream.can_comment?(post).should be_true
end end
it 'returns true if person is remote and is a contact' do it 'allows me to comment on a remote contacts post' do
Contact.create!(:user => @stream.user, :person => @person) Contact.create!(:user => @stream.user, :person => @person)
post = Factory(:status_message, :author => @person) post = Factory(:status_message, :author => @person)
@stream.can_comment?(post).should be_true @stream.can_comment?(post).should be_true
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter