Merge branch 'master' of github.com:diaspora/diaspora_rails
This commit is contained in:
commit
ab086e5b0e
24 changed files with 211 additions and 158 deletions
|
|
@ -4,6 +4,9 @@ class CommentsController < ApplicationController
|
|||
def create
|
||||
target = Post.first(:id => params[:comment][:post_id])
|
||||
text = params[:comment][:text]
|
||||
puts params.inspect
|
||||
|
||||
|
||||
if current_user.comment text, :on => target
|
||||
render :text => "Woo!"
|
||||
else
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ class FriendsController < ApplicationController
|
|||
|
||||
def show
|
||||
@friend = Friend.where(:id => params[:id]).first
|
||||
@friend_profile = @friend.profile
|
||||
@friend_posts = Post.where(:person_id => @friend.id).sort(:created_at.desc)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
module ApplicationHelper
|
||||
require 'lib/common'
|
||||
include Diaspora::XMLParser
|
||||
def object_path(object)
|
||||
eval("#{object.class.to_s.underscore}_path(object)")
|
||||
end
|
||||
|
|
@ -7,46 +9,6 @@ module ApplicationHelper
|
|||
object.attributes.keys
|
||||
end
|
||||
|
||||
def parse_sender_id_from_xml(xml)
|
||||
doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks }
|
||||
doc.xpath("/XML/head/sender/email").text.to_s
|
||||
end
|
||||
|
||||
def parse_sender_object_from_xml(xml)
|
||||
sender_id = parse_sender_id_from_xml(xml)
|
||||
Friend.where(:email => sender_id).first
|
||||
end
|
||||
|
||||
def parse_body_contents_from_xml(xml)
|
||||
doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks }
|
||||
doc.xpath("/XML/posts/post")
|
||||
end
|
||||
|
||||
def parse_objects_from_xml(xml)
|
||||
objects = []
|
||||
sender = parse_sender_object_from_xml(xml)
|
||||
body = parse_body_contents_from_xml(xml)
|
||||
body.children.each do |post|
|
||||
begin
|
||||
object = post.name.camelize.constantize.from_xml post.to_s
|
||||
object.person = sender if object.is_a? Post
|
||||
objects << object
|
||||
rescue
|
||||
puts "Not a real type: #{object.to_s}"
|
||||
end
|
||||
end
|
||||
objects
|
||||
end
|
||||
|
||||
def store_objects_from_xml(xml)
|
||||
objects = parse_objects_from_xml(xml)
|
||||
|
||||
objects.each do |p|
|
||||
p.save if p.respond_to?(:person) && !(p.person.nil?) #WTF
|
||||
#p.save if p.respond_to?(:person) && !(p.person == nil) #WTF
|
||||
end
|
||||
end
|
||||
|
||||
def mine?(post)
|
||||
post.person == User.first
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ module StatusMessagesHelper
|
|||
def my_latest_message
|
||||
message = StatusMessage.my_newest
|
||||
unless message.nil?
|
||||
return message.message + " " + how_long_ago(message)
|
||||
return message.message + " - " + how_long_ago(message)
|
||||
else
|
||||
return "No message to display."
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,18 +3,15 @@ class Person
|
|||
include ROXML
|
||||
|
||||
xml_accessor :email
|
||||
xml_accessor :real_name
|
||||
|
||||
key :email, String
|
||||
key :real_name, String
|
||||
|
||||
#key :post_ids, Array#, :typecast => ObjectId
|
||||
|
||||
one :profile, :class_name => 'Profile', :foreign_key => :person_id
|
||||
many :posts, :class_name => 'Post', :foreign_key => :person_id
|
||||
|
||||
validates_presence_of :email, :real_name
|
||||
validates_presence_of :email
|
||||
|
||||
# def newest(type = nil)
|
||||
# type.constantize.where(:person_id => id).last
|
||||
# end
|
||||
def real_name
|
||||
self.profile.first_name + " " + self.profile.last_name
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,19 +8,13 @@ class Post
|
|||
xml_accessor :_id
|
||||
|
||||
key :person_id, ObjectId
|
||||
belongs_to :person, :class_name => 'Person'
|
||||
|
||||
|
||||
many :comments, :class_name => 'Comment', :foreign_key => :post_id
|
||||
belongs_to :person, :class_name => 'Person'
|
||||
|
||||
timestamps!
|
||||
|
||||
|
||||
|
||||
after_save :send_to_view
|
||||
#validates_presence_of :person
|
||||
|
||||
|
||||
|
||||
def self.stream
|
||||
Post.sort(:created_at.desc).all
|
||||
|
|
@ -43,8 +37,7 @@ class Post
|
|||
protected
|
||||
|
||||
def send_to_view
|
||||
self.reload
|
||||
WebSocket.update_clients(self)
|
||||
WebSocket.update_clients(self)
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
13
app/models/profile.rb
Normal file
13
app/models/profile.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
class Profile
|
||||
include MongoMapper::Document
|
||||
|
||||
key :first_name, String
|
||||
key :last_name, String
|
||||
|
||||
key :person_id, ObjectId
|
||||
|
||||
belongs_to :person
|
||||
|
||||
validates_presence_of :first_name, :last_name, :person_id
|
||||
|
||||
end
|
||||
|
|
@ -14,6 +14,7 @@ class User < Person
|
|||
Comment.new(:person_id => self.id, :text => text, :post => options[:on]).save
|
||||
end
|
||||
|
||||
validates_presence_of :profile
|
||||
|
||||
before_validation :do_bad_things
|
||||
def do_bad_things
|
||||
|
|
|
|||
12
app/views/bookmarks/_form.html.haml
Normal file
12
app/views/bookmarks/_form.html.haml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
= form_for @bookmark do |f|
|
||||
= f.error_messages
|
||||
%p
|
||||
= f.label :title
|
||||
%br
|
||||
= f.text_field :title
|
||||
%p
|
||||
= f.label :link
|
||||
%br
|
||||
= f.text_field :link
|
||||
%p
|
||||
= f.submit
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
= form_for Comment.new, :remote => true do |f|
|
||||
= f.error_messages
|
||||
= form_tag("/comments", :remote => true, :class =>"new_comment", :id => "new_comment-#{post.id}") do
|
||||
%p
|
||||
= f.text_field :text, :value => "dislike!"
|
||||
= f.hidden_field :post_id, :value => post.id
|
||||
= f.submit 'comment', :class => 'button'
|
||||
= text_field_tag "comment_text", 'dislike!', :size => 30, :name => 'comment[text]'
|
||||
= hidden_field_tag "comment_post_id", "#{post.id}", :name => "comment[post_id]"
|
||||
= submit_tag 'comment', :id => "comment_submit_#{post.id}", :name => "commit"
|
||||
|
|
|
|||
|
|
@ -2,10 +2,6 @@
|
|||
|
||||
= form_for @friend do |f|
|
||||
= f.error_messages
|
||||
%p
|
||||
= f.label :real_name
|
||||
%br
|
||||
= f.text_field :real_name
|
||||
%p
|
||||
= f.label :email
|
||||
%br
|
||||
|
|
|
|||
|
|
@ -1,5 +1,22 @@
|
|||
%h1= "#{@friend.real_name}'s network stream"
|
||||
%h1= "#{@friend.real_name}"
|
||||
|
||||
- if @friend_profile
|
||||
%p
|
||||
%b First Name
|
||||
%p
|
||||
= @friend_profile.first_name
|
||||
%p
|
||||
%b Last Name
|
||||
%p
|
||||
= @friend_profile.last_name
|
||||
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
|
||||
- if @friend.posts
|
||||
%h3 stream
|
||||
%ul#stream
|
||||
- for post in @friend_posts
|
||||
= render type_partial(post), :post => post
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
= stylesheet_link_tag "blueprint/screen", :media => 'screen'
|
||||
= stylesheet_link_tag "application"
|
||||
/= javascript_include_tag"http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"
|
||||
/= javascript_include_tag"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"
|
||||
= javascript_include_tag 'jquery142', 'rails', 'view'
|
||||
= javascript_include_tag 'tiny_mce/tiny_mce.js'
|
||||
|
||||
|
|
@ -30,17 +30,17 @@
|
|||
ws = new WebSocket("ws://#{request.host}:8080/");
|
||||
ws.onmessage = function(evt) {
|
||||
var obj = jQuery.parseJSON(evt.data);
|
||||
if((location.href.indexOf(obj['class']) != -1 ) || (location.pathname == '/')) {
|
||||
$("#stream").prepend($(obj['html']).fadeIn("fast"));
|
||||
};
|
||||
}
|
||||
ws.onclose = function() { debug("socket closed"); };
|
||||
ws.onopen = function() {
|
||||
ws.send(location.pathname);
|
||||
debug("connected...");
|
||||
};
|
||||
debug("got a " + obj['class']);
|
||||
if((location.href.indexOf(obj['class']) != -1 ) || (location.pathname == '/')) {
|
||||
$("#stream").prepend($(obj['html']).fadeIn("fast"));
|
||||
};
|
||||
};
|
||||
ws.onclose = function() { debug("socket closed"); };
|
||||
ws.onopen = function() {
|
||||
ws.send(location.pathname);
|
||||
debug("connected...");
|
||||
};
|
||||
});
|
||||
});
|
||||
%body
|
||||
- flash.each do |name, msg|
|
||||
= content_tag :div, msg, :id => "flash_#{name}"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
= link_to_person post.person
|
||||
= post.message
|
||||
%div.time
|
||||
= link_to "#{time_ago_in_words(post.updated_at)} ago", status_message_path(post)
|
||||
= link_to(how_long_ago(post), status_message_path(post))
|
||||
= render "comments/comments", :post => post
|
||||
- if mine?(post)
|
||||
= link_to 'Destroy', status_message_path(post), :confirm => 'Are you sure?', :method => :delete
|
||||
|
|
|
|||
|
|
@ -5,19 +5,26 @@ module WebSocket
|
|||
EM.next_tick {
|
||||
EM.add_timer(0.1) do
|
||||
@channel = EM::Channel.new
|
||||
puts @channel.inspect
|
||||
@view = ActionView::Base.new(ActionController::Base.view_paths, {})
|
||||
|
||||
class << @view
|
||||
include ApplicationHelper
|
||||
include Rails.application.routes.url_helpers
|
||||
include ActionController::RequestForgeryProtection::ClassMethods
|
||||
include ActionView::Helpers::FormTagHelper
|
||||
include ActionView::Helpers::UrlHelper
|
||||
def protect_against_forgery?
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080, :debug =>false) do |ws|
|
||||
EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080, :debug =>true) do |ws|
|
||||
ws.onopen {
|
||||
sid = @channel.subscribe { |msg| ws.send msg }
|
||||
|
||||
ws.onmessage { |msg|}#@channel.push msg; puts msg}
|
||||
ws.onmessage { |msg| }#@channel.push msg; puts msg}
|
||||
|
||||
ws.onclose { @channel.unsubscribe(sid) }
|
||||
}
|
||||
|
|
@ -29,8 +36,18 @@ module WebSocket
|
|||
end
|
||||
|
||||
def self.view_hash(object)
|
||||
v = WebSocket.view_for(object)
|
||||
puts v
|
||||
begin
|
||||
puts "I be working hard"
|
||||
v = WebSocket.view_for(object)
|
||||
puts v.inspect
|
||||
|
||||
rescue Exception => e
|
||||
puts "in failzord " + v.inspect
|
||||
puts object.inspect
|
||||
puts e.message
|
||||
raise e
|
||||
end
|
||||
puts "i made it here"
|
||||
{:class =>object.class.to_s.underscore.pluralize, :html => v}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,47 @@
|
|||
module Diaspora
|
||||
module XMLParser
|
||||
def parse_sender_id_from_xml(xml)
|
||||
doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks }
|
||||
doc.xpath("/XML/head/sender/email").text.to_s
|
||||
end
|
||||
|
||||
def parse_sender_object_from_xml(xml)
|
||||
sender_id = parse_sender_id_from_xml(xml)
|
||||
Friend.where(:email => sender_id).first
|
||||
end
|
||||
|
||||
def parse_body_contents_from_xml(xml)
|
||||
doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks }
|
||||
doc.xpath("/XML/posts/post")
|
||||
end
|
||||
|
||||
def parse_objects_from_xml(xml)
|
||||
objects = []
|
||||
sender = parse_sender_object_from_xml(xml)
|
||||
body = parse_body_contents_from_xml(xml)
|
||||
body.children.each do |post|
|
||||
begin
|
||||
object = post.name.camelize.constantize.from_xml post.to_s
|
||||
object.person = sender if object.is_a? Post
|
||||
objects << object
|
||||
rescue
|
||||
puts "Not a real type: #{object.to_s}"
|
||||
end
|
||||
end
|
||||
objects
|
||||
end
|
||||
|
||||
def store_objects_from_xml(xml)
|
||||
objects = parse_objects_from_xml(xml)
|
||||
|
||||
objects.each do |p|
|
||||
p.save if p.respond_to?(:person) && !(p.person.nil?) #WTF
|
||||
#p.save if p.respond_to?(:person) && !(p.person == nil) #WTF
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
module Webhooks
|
||||
def self.included(klass)
|
||||
klass.class_eval do
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
# require 'addressable/uri'
|
||||
# require 'eventmachine'
|
||||
# require 'em-http'
|
||||
|
||||
class MessageHandler
|
||||
|
||||
NUM_TRIES = 3
|
||||
|
|
@ -25,7 +21,7 @@ class MessageHandler
|
|||
case query.type
|
||||
when :post
|
||||
http = EventMachine::HttpRequest.new(query.destination).post :timeout => TIMEOUT, :body =>{:xml => query.body}
|
||||
http.callback {puts query.inspect; process}
|
||||
http.callback {process}
|
||||
when :get
|
||||
http = EventMachine::HttpRequest.new(query.destination).get :timeout => TIMEOUT
|
||||
http.callback {send_to_seed(query, http.response); process}
|
||||
|
|
@ -34,6 +30,7 @@ class MessageHandler
|
|||
end
|
||||
|
||||
http.errback {
|
||||
puts query.destination + " failed!"
|
||||
query.try_count +=1
|
||||
@queue.push query unless query.try_count >= NUM_TRIES
|
||||
process
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ $(document).ready(function(){
|
|||
$('#bookmark_title').click(clearForm);
|
||||
|
||||
$('#bookmark_link').click(clearForm);
|
||||
$('#debug_more').hide();
|
||||
|
||||
function clearForm(){
|
||||
$(this).val("");
|
||||
|
|
|
|||
|
|
@ -1,11 +1,30 @@
|
|||
#For Guidance
|
||||
#http://github.com/thoughtbot/factory_girl
|
||||
#http://railscasts.com/episodes/158-factories-not-fixtures
|
||||
# http://railscasts.com/episodes/158-factories-not-fixtures
|
||||
|
||||
|
||||
Factory.define :profile do |p|
|
||||
p.first_name "Robert"
|
||||
p.last_name "Grimm"
|
||||
p.person Person.new( :email => "bob@aol.com" )
|
||||
end
|
||||
|
||||
Factory.define :person do |p|
|
||||
p.email "bob@aol.com"
|
||||
p.profile Profile.new( :first_name => "Robert", :last_name => "Grimm" )
|
||||
end
|
||||
|
||||
Factory.define :user do |u|
|
||||
u.sequence(:email) {|n| "bob#{n}@aol.com"}
|
||||
u.password "bluepin7"
|
||||
u.password_confirmation "bluepin7"
|
||||
u.profile Profile.new( :first_name => "Bob", :last_name => "Smith" )
|
||||
end
|
||||
|
||||
Factory.define :friend do |f|
|
||||
f.real_name 'John Doe'
|
||||
f.email 'max@max.com'
|
||||
f.url 'http://max.com/'
|
||||
f.profile Profile.new( :first_name => "Robert", :last_name => "Grimm" )
|
||||
end
|
||||
|
||||
Factory.define :status_message do |m|
|
||||
|
|
@ -17,12 +36,6 @@ Factory.define :blog do |b|
|
|||
b.sequence(:body) {|n| "jimmy's huge #{n} whales"}
|
||||
end
|
||||
|
||||
Factory.define :user do |u|
|
||||
u.real_name 'Bob Smith'
|
||||
u.sequence(:email) {|n| "bob#{n}@aol.com"}
|
||||
u.password "bluepin7"
|
||||
u.password_confirmation "bluepin7"
|
||||
end
|
||||
|
||||
Factory.define :bookmark do |b|
|
||||
b.link "http://www.yahooligans.com/"
|
||||
|
|
@ -31,4 +44,4 @@ end
|
|||
Factory.define :post do |p|
|
||||
end
|
||||
|
||||
Factory.define(:comment) {}
|
||||
Factory.define(:comment) {}
|
||||
|
|
|
|||
|
|
@ -15,19 +15,7 @@ describe "parser in application helper" do
|
|||
store_objects_from_xml(xml)
|
||||
StatusMessage.count.should == 0
|
||||
end
|
||||
it 'should discard posts where it does not know the type' do
|
||||
xml = "<XML>
|
||||
<head>
|
||||
<sender>
|
||||
<email>#{Friend.first.email}</email>
|
||||
</sender>
|
||||
</head><posts>
|
||||
<post><status_message>\n <message>Here is another message</message>\n <owner>a@a.com</owner>\n <snippet>a@a.com</snippet>\n <source>a@a.com</source>\n</status_message></post> <post><not_a_real_type></not_a_real_type></post> <post><status_message>\n <message>HEY DUDE</message>\n <owner>a@a.com</owner>\n <snippet>a@a.com</snippet>\n <source>a@a.com</source>\n</status_message></post>
|
||||
</posts></XML>"
|
||||
store_objects_from_xml(xml)
|
||||
Post.count.should == 2
|
||||
Post.first.person.email.should == Friend.first.email
|
||||
end
|
||||
|
||||
it "should reject xml with no sender" do
|
||||
xml = "<XML>
|
||||
<head>
|
||||
|
|
@ -40,6 +28,7 @@ describe "parser in application helper" do
|
|||
Post.count.should == 0
|
||||
|
||||
end
|
||||
|
||||
it "should reject xml with a sender not in the database" do
|
||||
xml = "<XML>
|
||||
<head>
|
||||
|
|
@ -54,6 +43,7 @@ describe "parser in application helper" do
|
|||
store_objects_from_xml(xml)
|
||||
Post.count.should == 0
|
||||
end
|
||||
|
||||
it 'should discard types which are not of type post' do
|
||||
xml = "<XML>
|
||||
<head>
|
||||
|
|
@ -62,13 +52,11 @@ describe "parser in application helper" do
|
|||
</sender>
|
||||
</head>
|
||||
<posts>
|
||||
<post><status_message>\n <message>Here is another message</message>\n <owner>a@a.com</owner>\n <snippet>a@a.com</snippet>\n <source>a@a.com</source>\n</status_message></post>
|
||||
<post><friend></friend></post>
|
||||
<post><status_message>\n <message>HEY DUDE</message>\n <owner>a@a.com</owner>\n <snippet>a@a.com</snippet>\n <source>a@a.com</source>\n</status_message></post>
|
||||
</posts></XML>"
|
||||
|
||||
store_objects_from_xml(xml)
|
||||
Post.count.should == 2
|
||||
Post.first.person.email.should == Friend.first.email
|
||||
Post.count.should == 0
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,21 +2,15 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
|||
|
||||
describe Friend do
|
||||
|
||||
it 'should require a diaspora username and diaspora url' do
|
||||
n = Factory.build(:friend, :url => nil)
|
||||
n.valid?.should be false
|
||||
n.url = "http://max.com/"
|
||||
n.valid?.should be true
|
||||
describe 'requirements' do
|
||||
it 'should include a url' do
|
||||
n = Factory.build(:friend, :url => nil)
|
||||
n.valid?.should be false
|
||||
n.url = "http://max.com/"
|
||||
n.valid?.should be true
|
||||
end
|
||||
end
|
||||
|
||||
it 'should require a real name' do
|
||||
n = Factory.build(:friend, :real_name => nil)
|
||||
n.valid?.should be false
|
||||
n.real_name = "John Smith"
|
||||
n.valid?.should be true
|
||||
end
|
||||
|
||||
|
||||
it 'should validate its url' do
|
||||
friend = Factory.build(:friend)
|
||||
|
||||
|
|
@ -65,23 +59,4 @@ describe Friend do
|
|||
friend.url = "http:///www.asodij.com/"
|
||||
friend.valid?.should == false
|
||||
end
|
||||
|
||||
describe "XML" do
|
||||
before do
|
||||
@f = Factory.build(:friend)
|
||||
@xml = "<friend>\n <url>#{@f.url}</url>\n <email>#{@f.email}</email>\n <real_name>#{@f.real_name}</real_name>\n</friend>"
|
||||
end
|
||||
|
||||
it 'should serialize to XML' do
|
||||
@f.to_xml.to_s.should == @xml
|
||||
end
|
||||
|
||||
it 'should marshal serialized XML to object' do
|
||||
parsed = Friend.from_xml(@xml)
|
||||
parsed.email.should == @f.email
|
||||
parsed.url.should == @f.url
|
||||
parsed.valid?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
4
spec/models/person_spec.rb
Normal file
4
spec/models/person_spec.rb
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Person do
|
||||
end
|
||||
32
spec/models/profile_spec.rb
Normal file
32
spec/models/profile_spec.rb
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Profile do
|
||||
before do
|
||||
@person = Factory.build(:person)
|
||||
end
|
||||
|
||||
describe 'requirements' do
|
||||
it "should include a first name" do
|
||||
@person.profile = Factory.build(:profile, :person => @person, :first_name => nil)
|
||||
@person.profile.valid?.should be false
|
||||
@person.profile.first_name = "Bob"
|
||||
@person.profile.valid?.should be true
|
||||
end
|
||||
|
||||
it "should include a last name" do
|
||||
@person.profile = Factory.build(:profile, :person => @person, :last_name => nil)
|
||||
@person.profile.valid?.should be false
|
||||
@person.profile.last_name = "Smith"
|
||||
@person.profile.valid?.should be true
|
||||
end
|
||||
|
||||
it "should include a person" do
|
||||
profile = Factory.build(:profile, :person => nil)
|
||||
profile.valid?.should be false
|
||||
profile.person = @person
|
||||
profile.valid?.should be true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
@ -1,20 +1,9 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe User do
|
||||
it "should require a real name" do
|
||||
u = Factory.build(:user, :real_name => nil)
|
||||
u.valid?.should be false
|
||||
u.real_name = "John Smith"
|
||||
u.valid?.should be true
|
||||
end
|
||||
it "should create a valid user with the factory" do
|
||||
u = Factory.build(:user)
|
||||
u.valid?.should be true
|
||||
end
|
||||
it "should be a person" do
|
||||
n = Person.count
|
||||
Factory.create(:user)
|
||||
Person.count.should == n+1
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue