Merge branch 'master' of github.com:diaspora/diaspora_rails

This commit is contained in:
Raphael 2010-07-12 18:31:46 -07:00
commit 2f265a8483
6 changed files with 29 additions and 6 deletions

View file

@ -18,7 +18,7 @@ class Bookmark < Post
def clean_link
if self.link
self.link = 'http://' + self.link unless self.link.match('http://' || 'https://')
self.link = 'http://' + self.link unless self.link.match('https?://')
self.link = self.link + '/' if self.link[-1,1] != '/'
end
end

View file

@ -2,10 +2,11 @@ class Person
include MongoMapper::Document
include ROXML
xml_accessor :_id
xml_accessor :email
xml_accessor :url
xml_accessor :profile, :as => Profile
xml_accessor :_id
key :email, String
key :url, String

View file

@ -17,6 +17,11 @@ class Request
validates_presence_of :destination_url, :callback_url
#validates_format_of :destination_url, :with =>
#/^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix
before_validation :clean_link
scope :for_user, lambda{ |user| where(:destination_url => user.url) }
scope :from_user, lambda{ |user| where(:destination_url.ne => user.url) }
@ -30,5 +35,14 @@ class Request
p.active = true
p.save
end
protected
def clean_link
if self.destination_url
self.destination_url = 'http://' + self.destination_url unless self.destination_url.match('https?://')
self.destination_url = self.destination_url + '/' if self.destination_url[-1,1] != '/'
end
end
end

View file

@ -19,7 +19,6 @@ class Retraction
attr_accessor :type
def perform
puts('GO GO GO')
self.type.constantize.destroy(self.post_id)
end
@ -35,7 +34,7 @@ class Retraction
def self.type_name(object)
if object.is_a? Post
object.class
elsif object.is_a? User
elsif object.is_a? Person
'Person'
else
'Clowntown'

View file

@ -141,6 +141,17 @@ describe "parser in application helper" do
Person.where(:url => @person.url).first.active.should be true
end
it 'should marshal a retraction for a person' do
retraction = Retraction.for(@user)
request = Retraction.build_xml_for( [retraction] )
Person.count.should == 2
store_objects_from_xml( request )
Person.count.should == 1
end
end
end

View file

@ -62,11 +62,9 @@ describe Person do
f = Factory.create(:person, :active => true)
Person.friends.all.count.should == 1
u.unfriend(f.id)
Person.friends.all.count.should == 0
end
end