Skip to content
Extraits de code Groupes Projets
Valider 5d924dad rédigé par maxwell's avatar maxwell
Parcourir les fichiers

MS DG; 19 failing specs left

parent 7a1011c4
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 48 ajouts et 51 suppressions
...@@ -16,9 +16,8 @@ class ApplicationController < ActionController::Base ...@@ -16,9 +16,8 @@ class ApplicationController < ActionController::Base
end end
def set_friends_and_status def set_friends_and_status
@friends = Person.friends.all if current_user @friends = current_user.friends if current_user
@latest_status_message = StatusMessage.newest(current_user) if current_user @latest_status_message = StatusMessage.newest_for(current_user) if current_user
end end
def count_requests def count_requests
......
...@@ -8,7 +8,7 @@ module ApplicationHelper ...@@ -8,7 +8,7 @@ module ApplicationHelper
end end
def mine?(post) def mine?(post)
post.person == User.owner post.person.id == current_user.person.id
end end
def type_partial(post) def type_partial(post)
......
...@@ -87,7 +87,7 @@ class Person ...@@ -87,7 +87,7 @@ class Person
end end
def mine?(post) def mine?(post)
self == post.person self.id == post.person.id
end end
......
...@@ -35,19 +35,10 @@ class Post ...@@ -35,19 +35,10 @@ class Post
Post.sort(:created_at.desc).all Post.sort(:created_at.desc).all
end end
def self.newest(person = nil) def self.newest_for(person)
return self.last if person.nil?
self.first(:person_id => person.id, :order => '_id desc') self.first(:person_id => person.id, :order => '_id desc')
end end
def self.my_newest
self.newest(User.owner)
end
def self.newest_by_email(email)
self.newest(Person.first(:email => email))
end
#ENCRYPTION #ENCRYPTION
before_validation :sign_if_mine before_validation :sign_if_mine
validates_true_for :creator_signature, :logic => lambda {self.verify_creator_signature} validates_true_for :creator_signature, :logic => lambda {self.verify_creator_signature}
......
...@@ -44,6 +44,10 @@ class Retraction ...@@ -44,6 +44,10 @@ class Retraction
object.person.id object.person.id
end end
end end
def person
Person.first(:id => self.person_id)
end
#ENCRYPTION #ENCRYPTION
xml_reader :creator_signature xml_reader :creator_signature
......
...@@ -39,7 +39,7 @@ module Diaspora ...@@ -39,7 +39,7 @@ module Diaspora
end end
def people_with_permissions def people_with_permissions
self.person.owner.friends self.person.owner.friends.all
end end
def self.build_xml_for(posts) def self.build_xml_for(posts)
......
...@@ -14,6 +14,8 @@ class MessageHandler ...@@ -14,6 +14,8 @@ class MessageHandler
def add_post_request(destinations, body) def add_post_request(destinations, body)
b = CGI::escape( body ) b = CGI::escape( body )
puts body
puts destinations.inspect
[*destinations].each{|dest| @queue.push(Message.new(:post, dest, :body => b))} [*destinations].each{|dest| @queue.push(Message.new(:post, dest, :body => b))}
end end
......
...@@ -12,7 +12,7 @@ describe DashboardsController do ...@@ -12,7 +12,7 @@ describe DashboardsController do
sign_in :user, @user sign_in :user, @user
Factory.create :person Factory.create :person
get :index get :index
assigns[:friends].should == Person.friends.all assigns[:friends].should == @user.friends
end end
end end
...@@ -4,7 +4,7 @@ describe PublicsController do ...@@ -4,7 +4,7 @@ describe PublicsController do
render_views render_views
before do before do
@user = Factory.create(:user, :profile => Profile.new( :first_name => "bob", :last_name => "smith")) @user = Factory.create(:user)
@user.person.save @user.person.save
request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user) request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)
end end
......
...@@ -6,6 +6,9 @@ describe ApplicationHelper do ...@@ -6,6 +6,9 @@ describe ApplicationHelper do
before do before do
@user = Factory.create(:user) @user = Factory.create(:user)
@person = Factory.create(:person) @person = Factory.create(:person)
request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)
sign_in @user
@user.save
end end
it "should specifiy if a post is not owned user" do it "should specifiy if a post is not owned user" do
...@@ -14,7 +17,11 @@ describe ApplicationHelper do ...@@ -14,7 +17,11 @@ describe ApplicationHelper do
end end
it "should specifiy if a post is owned current user" do it "should specifiy if a post is owned current user" do
p = Factory.create(:post, :person => @user) ApplicatonHelper.any_instance.stub!(:current_user).and_return(@user)
p = Factory.create(:post, :person => @user.person)
puts p.person.id == @user.person.id
mine?(p).should be true mine?(p).should be true
end end
......
...@@ -86,7 +86,7 @@ describe Diaspora::Parser do ...@@ -86,7 +86,7 @@ describe Diaspora::Parser do
it 'should be able to correctly handle comments' do it 'should be able to correctly handle comments' do
person = Factory.create(:person, :email => "test@testing.com") person = Factory.create(:person, :email => "test@testing.com")
post = Factory.create(:status_message) post = Factory.create(:status_message, :person => @user.person)
comment = Factory.build(:comment, :post => post, :person => person, :text => "Freedom!") comment = Factory.build(:comment, :post => post, :person => person, :text => "Freedom!")
xml = "<XML> xml = "<XML>
<posts> <posts>
...@@ -166,12 +166,12 @@ describe Diaspora::Parser do ...@@ -166,12 +166,12 @@ describe Diaspora::Parser do
#Build xml for profile, clear profile #Build xml for profile, clear profile
xml = Post.build_xml_for(person.profile) xml = Post.build_xml_for(person.profile)
reloaded_person = Person.first(:id => id) reloaded_person = Person.first(:id => id)
reloaded_person.profile = nil reloaded_person.profile = nil
reloaded_person.save reloaded_person.profile.save
#Make sure profile is cleared #Make sure profile is cleared
Person.first(:id=> id).profile.should be nil Person.first(:id => id).profile.should be nil
old_profile.first_name.should == 'bob' old_profile.first_name.should == 'bob'
#Marshal profile #Marshal profile
...@@ -183,8 +183,6 @@ describe Diaspora::Parser do ...@@ -183,8 +183,6 @@ describe Diaspora::Parser do
person.profile.first_name.should == old_profile.first_name person.profile.first_name.should == old_profile.first_name
person.profile.last_name.should == old_profile.last_name person.profile.last_name.should == old_profile.last_name
person.profile.image_url.should == old_profile.image_url person.profile.image_url.should == old_profile.image_url
end end
end end
end end
......
...@@ -18,7 +18,7 @@ describe Blog do ...@@ -18,7 +18,7 @@ describe Blog do
describe "XML" do describe "XML" do
it 'should serialize to XML' do it 'should serialize to XML' do
body = Factory.create(:blog, :title => "yessir", :body => "penguins") body = Factory.create(:blog, :title => "yessir", :body => "penguins", :person => @user.person)
body.to_xml.to_s.should include "<title>yessir</title>" body.to_xml.to_s.should include "<title>yessir</title>"
body.to_xml.to_s.should include "<body>penguins</body>" body.to_xml.to_s.should include "<body>penguins</body>"
end end
......
...@@ -57,8 +57,8 @@ describe Bookmark do ...@@ -57,8 +57,8 @@ describe Bookmark do
describe "XML" do describe "XML" do
it 'should serialize to XML' do it 'should serialize to XML' do
Factory.create(:user) u = Factory.create(:user)
message = Factory.create(:bookmark, :title => "Reddit", :link => "http://reddit.com/") message = Factory.create(:bookmark, :title => "Reddit", :link => "http://reddit.com/", :person => u.person)
message.to_xml.to_s.should include "<title>Reddit</title>" message.to_xml.to_s.should include "<title>Reddit</title>"
message.to_xml.to_s.should include "<link>http://reddit.com/</link>" message.to_xml.to_s.should include "<link>http://reddit.com/</link>"
end end
......
...@@ -17,7 +17,7 @@ describe Comment do ...@@ -17,7 +17,7 @@ describe Comment do
it "should be able to comment on a person's status" do it "should be able to comment on a person's status" do
person= Factory.create :person person= Factory.create :person
status = Factory.create(:status_message, :person => person) status = Factory.create(:status_message, :person => person)
@user.person.comment "sup dog", :on => status @user.comment "sup dog", :on => status
StatusMessage.first.comments.first.text.should == "sup dog" StatusMessage.first.comments.first.text.should == "sup dog"
StatusMessage.first.comments.first.person.should == @user.person StatusMessage.first.comments.first.person.should == @user.person
...@@ -32,30 +32,33 @@ describe Comment do ...@@ -32,30 +32,33 @@ describe Comment do
describe 'comment propagation' do describe 'comment propagation' do
before do before do
@person = Factory.create(:person) @person = Factory.create(:person)
@person_two = Factory.create(:person) @user.friends << Factory.create(:person)
@person_status = Factory.create(:status_message, :person => @person) @user.save
@user_status = Factory.create(:status_message, :person => @user.person)
@person_status = Factory.build(:status_message, :person => @person)
@user_status = Factory.build(:status_message, :person => @user.person)
end end
it "should send a user's comment on a person's post to that person" do it "should send a user's comment on a person's post to that person" do
Comment.send(:class_variable_get, :@@queue).should_receive(:add_post_request) Comment.send(:class_variable_get, :@@queue).should_receive(:add_post_request)
@user.person.comment "yo", :on => @person_status @user.comment "yo", :on => @person_status
end end
it 'should send a user comment on his own post to lots of people' do it 'should send a user comment on his own post to lots of people' do
allowed_urls = @user_status.people_with_permissions.map!{|x| x = x.url + "receive/"} allowed_urls = @user_status.people_with_permissions.map!{|x| x = x.url + "receive/"}
Comment.send(:class_variable_get, :@@queue).should_receive(:add_post_request).with(allowed_urls, anything )
@user.person.comment "yo", :on => @user_status Comment.send(:class_variable_get, :@@queue).should_receive(:add_post_request).with(allowed_urls, anything)
@user.comment "yo", :on => @user_status
end end
it 'should send a comment a person made on your post to all people' do it 'should send a comment a person made on your post to all people' do
Comment.send(:class_variable_get, :@@queue).should_receive(:add_post_request) Comment.send(:class_variable_get, :@@queue).should_receive(:add_post_request)
com = Comment.create(:person => @person, :text => "balls", :post => @user_status) Comment.create(:person => @person, :text => "balls", :post => @user_status)
end end
it 'should not send a comment a person made on a person post to anyone' do it 'should not send a comment a person made on a person post to anyone' do
Comment.send(:class_variable_get, :@@queue).should_not_receive(:add_post_request) Comment.send(:class_variable_get, :@@queue).should_not_receive(:add_post_request)
com = Comment.create(:person => @person, :text => "balls", :post => @person_status) Comment.create(:person => @person, :text => "balls", :post => @person_status)
end end
end end
end end
......
...@@ -21,7 +21,7 @@ describe Post do ...@@ -21,7 +21,7 @@ describe Post do
before do before do
@person_one = Factory.create(:person, :email => "some@dudes.com") @person_one = Factory.create(:person, :email => "some@dudes.com")
@person_two = Factory.create(:person, :email => "other@dudes.com") @person_two = Factory.create(:person, :email => "other@dudes.com")
(2..4).each {|n| Blog.create(:title => "title #{n}", :body => "test #{n}", :person => @person_one.person)} (2..4).each {|n| Blog.create(:title => "title #{n}", :body => "test #{n}", :person => @person_one)}
(5..8).each { |n| Blog.create(:title => "title #{n}",:body => "test #{n}", :person => @user.person)} (5..8).each { |n| Blog.create(:title => "title #{n}",:body => "test #{n}", :person => @user.person)}
(9..11).each { |n| Blog.create(:title => "title #{n}",:body => "test #{n}", :person => @person_two)} (9..11).each { |n| Blog.create(:title => "title #{n}",:body => "test #{n}", :person => @person_two)}
...@@ -30,20 +30,13 @@ describe Post do ...@@ -30,20 +30,13 @@ describe Post do
end end
it "should give the most recent blog title and body from owner" do it "should give the most recent blog title and body from owner" do
blog = Blog.my_newest() blog = Blog.newest_for(@user.person)
blog.person.email.should == @user.email blog.person.email.should == @user.person.email
blog.class.should == Blog blog.class.should == Blog
blog.title.should == "title 8" blog.title.should == "title 8"
blog.body.should == "test 8" blog.body.should == "test 8"
end end
it "should give the most recent blog body for a given email" do
blog = Blog.newest_by_email("some@dudes.com")
blog.person.email.should == @person_one.email
blog.class.should == Blog
blog.title.should == "title 4"
blog.body.should == "test 4"
end
end end
describe "stream" do describe "stream" do
...@@ -80,14 +73,14 @@ describe Post do ...@@ -80,14 +73,14 @@ describe Post do
describe 'xml' do describe 'xml' do
it 'should serialize to xml with its person' do it 'should serialize to xml with its person' do
message = Factory.create(:status_message, :person => @user.person) message = Factory.create(:status_message, :person => @user.person)
(message.to_xml.to_s.include? @user.email).should == true (message.to_xml.to_s.include? @user.person.email).should == true
end end
end end
describe 'deletion' do describe 'deletion' do
it 'should delete a posts comments on delete' do it 'should delete a posts comments on delete' do
post = Factory.create(:status_message, :person => @user.person) post = Factory.create(:status_message, :person => @user.person)
@user.comment "hey", :on=> post @user.comment "hey", :on => post
post.destroy post.destroy
Post.all(:id => post.id).empty?.should == true Post.all(:id => post.id).empty?.should == true
Comment.all(:text => "hey").empty?.should == true Comment.all(:text => "hey").empty?.should == true
......
...@@ -18,7 +18,7 @@ describe StatusMessage do ...@@ -18,7 +18,7 @@ describe StatusMessage do
describe "XML" do describe "XML" do
it 'should serialize to XML' do it 'should serialize to XML' do
message = Factory.create(:status_message, :message => "I hate WALRUSES!") message = Factory.create(:status_message, :message => "I hate WALRUSES!", :person => @user.person)
message.to_xml.to_s.should include "<message>I hate WALRUSES!</message>" message.to_xml.to_s.should include "<message>I hate WALRUSES!</message>"
end end
......
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