diff --git a/app/models/friend.rb b/app/models/friend.rb
index 7f3463dd2..dba24e580 100644
--- a/app/models/friend.rb
+++ b/app/models/friend.rb
@@ -1,16 +1,10 @@
-class Friend
- include Mongoid::Document
- include ROXML
+class Friend < Person
- xml_accessor :username
xml_accessor :url
- xml_accessor :real_name
- field :username
field :url
- field :real_name
- validates_presence_of :username, :url, :real_name
+ validates_presence_of :url
validates_format_of :url, :with =>
/^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix
diff --git a/app/models/user.rb b/app/models/user.rb
index 45624f10e..a1ac4217f 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,13 +1,8 @@
-class User
- include Mongoid::Document
+class User < Person
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable, :lockable and :timeoutable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
- field :real_name
-
- validates_presence_of :real_name
-
end
diff --git a/app/views/friends/index.html.haml b/app/views/friends/index.html.haml
index 044ade323..52abf1451 100644
--- a/app/views/friends/index.html.haml
+++ b/app/views/friends/index.html.haml
@@ -2,11 +2,13 @@
%table
%tr
- %th username
+ %th real name
+ %th email
%th url
- for friend in @friends
%tr
- %td= friend.username
+ %td= friend.real_name
+ %td= friend.email
%td= friend.url
%td= link_to 'Show', friend
%td= link_to 'Destroy', friend, :confirm => 'Are you sure?', :method => :delete
diff --git a/app/views/friends/new.html.haml b/app/views/friends/new.html.haml
index e9b1451be..161bd0250 100644
--- a/app/views/friends/new.html.haml
+++ b/app/views/friends/new.html.haml
@@ -3,9 +3,13 @@
= form_for @friend do |f|
= f.error_messages
%p
- = f.label :username
+ = f.label :real_name
%br
- = f.text_field :username
+ = f.text_field :real_name
+ %p
+ = f.label :email
+ %br
+ = f.text_field :email
%p
= f.label :url
%br
diff --git a/app/views/friends/show.html.haml b/app/views/friends/show.html.haml
index 034eb23ce..fedc3e2a3 100644
--- a/app/views/friends/show.html.haml
+++ b/app/views/friends/show.html.haml
@@ -1,8 +1,11 @@
- title "Friend"
%p
- %strong Username:
- = @friend.username
+ %strong Real Name:
+ = @friend.real_name
+%p
+ %strong Email:
+ = @friend.email
%p
%strong Url:
= @friend.url
diff --git a/app/views/users/index.html.haml b/app/views/users/index.html.haml
index f0c2e7f87..6f210359c 100644
--- a/app/views/users/index.html.haml
+++ b/app/views/users/index.html.haml
@@ -2,9 +2,11 @@
%table
%tr
- %th User
+ %th Real Name
+ %th email
%th Password
- for user in @users
%tr
+ %td= user.real_name
%td= user.email
%td= user.encrypted_password
diff --git a/spec/factories.rb b/spec/factories.rb
index 236e2984d..d995e1e88 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -4,7 +4,7 @@
Factory.define :friend do |f|
f.real_name 'John Doe'
- f.username 'max'
+ f.email 'max@max.com'
f.url 'http://max.com/'
end
diff --git a/spec/models/friend_spec.rb b/spec/models/friend_spec.rb
index 4ec6cf848..668e8e1f5 100644
--- a/spec/models/friend_spec.rb
+++ b/spec/models/friend_spec.rb
@@ -64,7 +64,7 @@ describe Friend do
describe "XML" do
before do
@f = Factory.build(:friend)
- @xml = "\n #{@f.username}\n #{@f.url}\n #{@f.real_name}\n"
+ @xml = "\n #{@f.url}\n #{@f.email}\n #{@f.real_name}\n"
end
it 'should serialize to XML' do
@@ -73,7 +73,7 @@ describe Friend do
it 'should marshal serialized XML to object' do
parsed = Friend.from_xml(@xml)
- parsed.username.should == @f.username
+ parsed.email.should == @f.email
parsed.url.should == @f.url
parsed.valid?.should be_true
end
diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb
index f8908e23e..7bc28571f 100644
--- a/spec/models/post_spec.rb
+++ b/spec/models/post_spec.rb
@@ -5,8 +5,6 @@ describe Post do
Factory.create(:user, :email => "bob@aol.com")
end
- describe 'requirements' do
- end
describe 'defaults' do
before do