person now has a url, and they cant add themselves any longer.... you need to add a url to your old development user, and we need to set it in the field
This commit is contained in:
parent
f9d4eff7b0
commit
19e03c7077
5 changed files with 27 additions and 30 deletions
|
|
@ -1,23 +1,4 @@
|
|||
class Friend < Person
|
||||
|
||||
xml_accessor :url
|
||||
|
||||
key :url, String
|
||||
|
||||
validates_presence_of :url
|
||||
validates_format_of :url, :with =>
|
||||
/^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix
|
||||
|
||||
#validate {self.url ! = User.first.url}
|
||||
|
||||
before_validation :clean_url
|
||||
|
||||
protected
|
||||
|
||||
def clean_url
|
||||
if self.url
|
||||
self.url = 'http://' + self.url unless self.url.match('http://' || 'https://')
|
||||
self.url = self.url + '/' if self.url[-1,1] != '/'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,15 +3,34 @@ class Person
|
|||
include ROXML
|
||||
|
||||
xml_accessor :email
|
||||
xml_accessor :url
|
||||
|
||||
key :email, String
|
||||
key :url, String, :unique => true
|
||||
|
||||
one :profile, :class_name => 'Profile', :foreign_key => :person_id
|
||||
many :posts, :class_name => 'Post', :foreign_key => :person_id
|
||||
|
||||
timestamps!
|
||||
|
||||
validates_presence_of :url
|
||||
validates_format_of :url, :with =>
|
||||
/^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix
|
||||
validates_presence_of :email
|
||||
|
||||
before_validation :clean_url
|
||||
|
||||
def real_name
|
||||
self.profile.first_name + " " + self.profile.last_name
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def clean_url
|
||||
self.url ||= "http://localhost:3000/" if self.class == User
|
||||
if self.url
|
||||
self.url = 'http://' + self.url unless self.url.match('http://' || 'https://')
|
||||
self.url = self.url + '/' if self.url[-1,1] != '/'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
class User < Person
|
||||
include MongoMapper::Document
|
||||
|
||||
timestamps!
|
||||
|
||||
# Include default devise modules. Others available are:
|
||||
# :token_authenticatable, :confirmable, :lockable and :timeoutable
|
||||
devise :database_authenticatable, :registerable,
|
||||
:recoverable, :rememberable, :trackable, :validatable
|
||||
|
||||
|
||||
|
||||
def comment(text, options = {})
|
||||
raise "Comment on what, motherfucker?" unless options[:on]
|
||||
Comment.new(:person_id => self.id, :text => text, :post => options[:on]).save
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ end
|
|||
|
||||
Factory.define :friend do |f|
|
||||
f.email 'max@max.com'
|
||||
f.url 'http://max.com/'
|
||||
f.sequence(:url) {|n|"http://max#{n}.com/"}
|
||||
f.profile Profile.new( :first_name => "Robert", :last_name => "Grimm" )
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ describe Post do
|
|||
|
||||
describe "stream" do
|
||||
before do
|
||||
@owner = Factory.create(:user, :email => "robert@grimm.com")
|
||||
@owner = Factory.build(:user)
|
||||
@friend_one = Factory.create(:friend, :email => "some@dudes.com")
|
||||
@friend_two = Factory.create(:friend, :email => "other@dudes.com")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue