From 720c68e2c6bb71b53fe6b226ced757966cf0dd17 Mon Sep 17 00:00:00 2001 From: ilya <ilya@laptop.(none)> Date: Fri, 25 Jun 2010 18:18:20 -0400 Subject: [PATCH] Specs all pass --- spec/lib/common_spec.rb | 4 ++-- spec/models/blogs_spec.rb | 30 +----------------------------- spec/models/bookmark_spec.rb | 6 ------ spec/models/post_spec.rb | 30 +++++++++++++++++++++++++++++- spec/models/status_message_spec.rb | 24 ------------------------ 5 files changed, 32 insertions(+), 62 deletions(-) diff --git a/spec/lib/common_spec.rb b/spec/lib/common_spec.rb index c8c14f7c4b..3b4be323bc 100644 --- a/spec/lib/common_spec.rb +++ b/spec/lib/common_spec.rb @@ -7,7 +7,7 @@ describe Diaspora do describe Webhooks do before do - Factory.create(:user, :email => "bob@aol.com") + @user = Factory.create(:user, :email => "bob@aol.com") end describe "header" do @@ -35,7 +35,7 @@ describe Diaspora do describe "body" do before do - @post = Factory.create(:status_message) + @post = Factory.create(:status_message, :person => @user) end it "should add the following methods to Post on inclusion" do diff --git a/spec/models/blogs_spec.rb b/spec/models/blogs_spec.rb index 25a3c1c70d..270339a85c 100644 --- a/spec/models/blogs_spec.rb +++ b/spec/models/blogs_spec.rb @@ -15,35 +15,7 @@ describe Blog do end - describe "newest" do - before do - @friend_one = Factory.create(:friend, :email => "some@dudes.com") - @friend_two = Factory.create(:friend, :email => "other@dudes.com") - (2..4).each {|n| Blog.create(:title => "title #{n}", :body => "test #{n}", :person => @friend_one)} - (5..8).each { |n| Blog.create(:title => "title #{n}",:body => "test #{n}", :person => @user)} - (9..11).each { |n| Blog.create(:title => "title #{n}",:body => "test #{n}", :person => @friend_two)} - - Factory.create(:status_message) - Factory.create(:bookmark) - 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.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 == @friend_one.email - blog.class.should == Blog - blog.title.should == "title 4" - blog.body.should == "test 4" - end - end - + describe "XML" do it 'should serialize to XML' do body = Factory.create(:blog, :title => "yessir", :body => "penguins") diff --git a/spec/models/bookmark_spec.rb b/spec/models/bookmark_spec.rb index 4d253a7a6e..32f326591c 100644 --- a/spec/models/bookmark_spec.rb +++ b/spec/models/bookmark_spec.rb @@ -8,12 +8,6 @@ describe Bookmark do bookmark.valid?.should be true end - it "should add an owner if none is present" do - Factory.create(:user, :email => "bob@aol.com") - n = Factory.create(:bookmark) - n.person.email.should == "bob@aol.com" - end - it 'should validate its link' do bookmark = Factory.build(:bookmark) diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 6e53277539..38d206dddf 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../spec_helper' describe Post do before do - Factory.create(:user, :email => "bob@aol.com") + @user = Factory.create(:user, :email => "bob@aol.com") end describe 'defaults' do @@ -17,7 +17,35 @@ describe Post do end + describe "newest" do + before do + @friend_one = Factory.create(:friend, :email => "some@dudes.com") + @friend_two = Factory.create(:friend, :email => "other@dudes.com") + (2..4).each {|n| Blog.create(:title => "title #{n}", :body => "test #{n}", :person => @friend_one)} + (5..8).each { |n| Blog.create(:title => "title #{n}",:body => "test #{n}", :person => @user)} + (9..11).each { |n| Blog.create(:title => "title #{n}",:body => "test #{n}", :person => @friend_two)} + Factory.create(:status_message) + Factory.create(:bookmark) + 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.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 == @friend_one.email + blog.class.should == Blog + blog.title.should == "title 4" + blog.body.should == "test 4" + end + end + describe "stream" do before do @owner = Factory.create(:user, :email => "robert@grimm.com") diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb index f57edea8de..4068972400 100644 --- a/spec/models/status_message_spec.rb +++ b/spec/models/status_message_spec.rb @@ -12,30 +12,6 @@ describe StatusMessage do n.valid?.should be true end - - it "should add an owner if none is present" do - n = Factory.create(:status_message) - n.person.email.should == "bob@aol.com" - end - - describe "newest" do - before do - @person_one = Factory.create(:friend,:email => "some@dudes.com") - (1..10).each { Factory.create(:status_message, :person => @person_one) } - (1..5).each { Factory.create(:status_message) } - Factory.create(:bookmark) - Factory.create(:bookmark, :person => @person_one) - end - - it "should give the most recent message from a friend" do - StatusMessage.newest(@person_one).message.should == "jimmy's 13 whales" - end - - it "should give the most recent message for a given email" do - StatusMessage.newest_by_email(@person_one.email).message.should == "jimmy's 28 whales" - end - end - describe "XML" do it 'should serialize to XML' do message = Factory.create(:status_message, :message => "I hate WALRUSES!") -- GitLab