MS DG; 19 failing specs left
This commit is contained in:
parent
7a1011c46c
commit
5d924dadf4
16 changed files with 48 additions and 51 deletions
|
|
@ -16,9 +16,8 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def set_friends_and_status
|
||||
@friends = Person.friends.all if current_user
|
||||
@latest_status_message = StatusMessage.newest(current_user) if current_user
|
||||
|
||||
@friends = current_user.friends if current_user
|
||||
@latest_status_message = StatusMessage.newest_for(current_user) if current_user
|
||||
end
|
||||
|
||||
def count_requests
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
def mine?(post)
|
||||
post.person == User.owner
|
||||
post.person.id == current_user.person.id
|
||||
end
|
||||
|
||||
def type_partial(post)
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class Person
|
|||
end
|
||||
|
||||
def mine?(post)
|
||||
self == post.person
|
||||
self.id == post.person.id
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,19 +35,10 @@ class Post
|
|||
Post.sort(:created_at.desc).all
|
||||
end
|
||||
|
||||
def self.newest(person = nil)
|
||||
return self.last if person.nil?
|
||||
|
||||
def self.newest_for(person)
|
||||
self.first(:person_id => person.id, :order => '_id desc')
|
||||
end
|
||||
|
||||
def self.my_newest
|
||||
self.newest(User.owner)
|
||||
end
|
||||
def self.newest_by_email(email)
|
||||
self.newest(Person.first(:email => email))
|
||||
end
|
||||
|
||||
#ENCRYPTION
|
||||
before_validation :sign_if_mine
|
||||
validates_true_for :creator_signature, :logic => lambda {self.verify_creator_signature}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,10 @@ class Retraction
|
|||
object.person.id
|
||||
end
|
||||
end
|
||||
|
||||
def person
|
||||
Person.first(:id => self.person_id)
|
||||
end
|
||||
|
||||
#ENCRYPTION
|
||||
xml_reader :creator_signature
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ module Diaspora
|
|||
end
|
||||
|
||||
def people_with_permissions
|
||||
self.person.owner.friends
|
||||
self.person.owner.friends.all
|
||||
end
|
||||
|
||||
def self.build_xml_for(posts)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ class MessageHandler
|
|||
|
||||
def add_post_request(destinations, body)
|
||||
b = CGI::escape( body )
|
||||
puts body
|
||||
puts destinations.inspect
|
||||
[*destinations].each{|dest| @queue.push(Message.new(:post, dest, :body => b))}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ describe DashboardsController do
|
|||
sign_in :user, @user
|
||||
Factory.create :person
|
||||
get :index
|
||||
assigns[:friends].should == Person.friends.all
|
||||
assigns[:friends].should == @user.friends
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ describe PublicsController do
|
|||
render_views
|
||||
|
||||
before do
|
||||
@user = Factory.create(:user, :profile => Profile.new( :first_name => "bob", :last_name => "smith"))
|
||||
@user = Factory.create(:user)
|
||||
@user.person.save
|
||||
request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ describe ApplicationHelper do
|
|||
before do
|
||||
@user = Factory.create(:user)
|
||||
@person = Factory.create(:person)
|
||||
request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)
|
||||
sign_in @user
|
||||
@user.save
|
||||
end
|
||||
|
||||
it "should specifiy if a post is not owned user" do
|
||||
|
|
@ -14,7 +17,11 @@ describe ApplicationHelper do
|
|||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ describe Diaspora::Parser do
|
|||
|
||||
it 'should be able to correctly handle comments' do
|
||||
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!")
|
||||
xml = "<XML>
|
||||
<posts>
|
||||
|
|
@ -166,12 +166,12 @@ describe Diaspora::Parser do
|
|||
|
||||
#Build xml for profile, clear 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.save
|
||||
reloaded_person.profile.save
|
||||
|
||||
#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'
|
||||
|
||||
#Marshal profile
|
||||
|
|
@ -183,8 +183,6 @@ describe Diaspora::Parser do
|
|||
person.profile.first_name.should == old_profile.first_name
|
||||
person.profile.last_name.should == old_profile.last_name
|
||||
person.profile.image_url.should == old_profile.image_url
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ describe Blog do
|
|||
|
||||
describe "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 "<body>penguins</body>"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ describe Bookmark do
|
|||
|
||||
describe "XML" do
|
||||
it 'should serialize to XML' do
|
||||
Factory.create(:user)
|
||||
message = Factory.create(:bookmark, :title => "Reddit", :link => "http://reddit.com/")
|
||||
u = Factory.create(:user)
|
||||
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 "<link>http://reddit.com/</link>"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ describe Comment do
|
|||
it "should be able to comment on a person's status" do
|
||||
person= Factory.create :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.person.should == @user.person
|
||||
|
|
@ -32,30 +32,33 @@ describe Comment do
|
|||
describe 'comment propagation' do
|
||||
before do
|
||||
@person = Factory.create(:person)
|
||||
@person_two = Factory.create(:person)
|
||||
@person_status = Factory.create(:status_message, :person => @person)
|
||||
@user_status = Factory.create(:status_message, :person => @user.person)
|
||||
@user.friends << Factory.create(:person)
|
||||
@user.save
|
||||
|
||||
@person_status = Factory.build(:status_message, :person => @person)
|
||||
@user_status = Factory.build(:status_message, :person => @user.person)
|
||||
end
|
||||
|
||||
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)
|
||||
@user.person.comment "yo", :on => @person_status
|
||||
@user.comment "yo", :on => @person_status
|
||||
end
|
||||
|
||||
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/"}
|
||||
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
|
||||
|
||||
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)
|
||||
com = Comment.create(:person => @person, :text => "balls", :post => @user_status)
|
||||
Comment.create(:person => @person, :text => "balls", :post => @user_status)
|
||||
end
|
||||
|
||||
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)
|
||||
com = Comment.create(:person => @person, :text => "balls", :post => @person_status)
|
||||
Comment.create(:person => @person, :text => "balls", :post => @person_status)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ describe Post do
|
|||
before do
|
||||
@person_one = Factory.create(:person, :email => "some@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)}
|
||||
(9..11).each { |n| Blog.create(:title => "title #{n}",:body => "test #{n}", :person => @person_two)}
|
||||
|
||||
|
|
@ -30,20 +30,13 @@ describe Post do
|
|||
end
|
||||
|
||||
it "should give the most recent blog title and body from owner" do
|
||||
blog = Blog.my_newest()
|
||||
blog.person.email.should == @user.email
|
||||
blog = Blog.newest_for(@user.person)
|
||||
blog.person.email.should == @user.person.email
|
||||
blog.class.should == Blog
|
||||
blog.title.should == "title 8"
|
||||
blog.body.should == "test 8"
|
||||
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
|
||||
|
||||
describe "stream" do
|
||||
|
|
@ -80,14 +73,14 @@ describe Post do
|
|||
describe 'xml' do
|
||||
it 'should serialize to xml with its person' do
|
||||
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
|
||||
|
||||
describe 'deletion' do
|
||||
it 'should delete a posts comments on delete' do
|
||||
post = Factory.create(:status_message, :person => @user.person)
|
||||
@user.comment "hey", :on=> post
|
||||
@user.comment "hey", :on => post
|
||||
post.destroy
|
||||
Post.all(:id => post.id).empty?.should == true
|
||||
Comment.all(:text => "hey").empty?.should == true
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ describe StatusMessage do
|
|||
|
||||
describe "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>"
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue