RS, IZ; ApplicationHelper specs now passed, specs for mine? moved into person spec as specs for owns?
This commit is contained in:
parent
6449d20687
commit
d130b82e42
4 changed files with 37 additions and 42 deletions
|
|
@ -8,7 +8,7 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
def mine?(post)
|
||||
post.person.id == current_user.person.id
|
||||
current_user.owns? post
|
||||
end
|
||||
|
||||
def type_partial(post)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
|
||||
include ApplicationHelper
|
||||
describe DashboardsController do
|
||||
render_views
|
||||
before do
|
||||
@user = Factory.create(:user)
|
||||
@user.person.save
|
||||
@person = Factory.create(:person)
|
||||
request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -5,23 +5,8 @@ describe ApplicationHelper do
|
|||
before do
|
||||
@user = Factory.create(:user)
|
||||
@person = Factory.create(:person)
|
||||
#env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)
|
||||
sign_in @user
|
||||
@user.save
|
||||
end
|
||||
|
||||
it "should specifiy if a post is not owned user" do
|
||||
p = Factory.create(:post, :person => @person)
|
||||
mine?(p).should be false
|
||||
end
|
||||
|
||||
it "should specifiy if a post is owned current user" do
|
||||
p = Factory.create(:post, :person => @user.person)
|
||||
|
||||
puts p.person.id == @user.person.id
|
||||
|
||||
mine?(p).should be true
|
||||
end
|
||||
|
||||
it "should provide a correct show path for a given person" do
|
||||
person_url(@person).should == "/people/#{@person.id}"
|
||||
|
|
|
|||
|
|
@ -1,39 +1,50 @@
|
|||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
|
||||
describe Person do
|
||||
before do
|
||||
@person = Factory.create(:person)
|
||||
end
|
||||
it 'should not allow two people with the same email' do
|
||||
person_one = Factory.create(:person)
|
||||
person_two = Factory.build(:person, :url => person_one.email)
|
||||
person_two = Factory.build(:person, :url => @person.email)
|
||||
person_two.valid?.should == false
|
||||
end
|
||||
|
||||
describe 'xml' do
|
||||
before do
|
||||
@xml = @person.to_xml.to_s
|
||||
end
|
||||
it 'should serialize to xml' do
|
||||
person = Factory.create(:person)
|
||||
xml = person.to_xml.to_s
|
||||
(xml.include? "person").should == true
|
||||
(@xml.include? "person").should == true
|
||||
end
|
||||
|
||||
it 'should have a profile in its xml' do
|
||||
person = Factory.create(:person)
|
||||
xml = person.to_xml.to_s
|
||||
(xml.include? "first_name").should == true
|
||||
(@xml.include? "first_name").should == true
|
||||
end
|
||||
end
|
||||
|
||||
it 'should know when a post belongs to it' do
|
||||
person_message = Factory.create(:status_message, :person => @person)
|
||||
person_two = Factory.create(:person)
|
||||
|
||||
@person.owns?(person_message).should be true
|
||||
person_two.owns?(person_message).should be false
|
||||
end
|
||||
|
||||
it 'should delete all of user except comments upon user deletion' do
|
||||
Factory.create(:user)
|
||||
|
||||
f = Factory.create(:person)
|
||||
p = Factory.create(:person)
|
||||
|
||||
Factory.create(:status_message, :person => f)
|
||||
Factory.create(:blog, :person => f)
|
||||
Factory.create(:bookmark, :person => f)
|
||||
Factory.create(:status_message, :person => f)
|
||||
s = Factory.create(:status_message, :person => p)
|
||||
s = Factory.create(:status_message, :person => @person)
|
||||
|
||||
Factory.create(:comment, :person_id => f.id, :text => "yes i do", :post => s)
|
||||
Factory.create(:comment, :person_id => f.id, :text => "i love you", :post => s)
|
||||
Factory.create(:comment, :person_id => f.id, :text => "hello", :post => s)
|
||||
Factory.create(:comment, :person_id => p.id, :text => "you are creepy", :post => s)
|
||||
Factory.create(:comment, :person_id => @person.id, :text => "you are creepy", :post => s)
|
||||
|
||||
f.destroy
|
||||
|
||||
|
|
@ -47,15 +58,14 @@ describe Person do
|
|||
user = Factory.create(:user)
|
||||
user.save
|
||||
|
||||
person = Factory.create(:person)
|
||||
|
||||
user.friends << person
|
||||
person.user_refs += 1
|
||||
person.save
|
||||
user.friends << @person
|
||||
@person.user_refs += 1
|
||||
@person.save
|
||||
|
||||
Person.all.count.should == 2
|
||||
user.friends.count.should == 1
|
||||
user.unfriend(person.id)
|
||||
user.unfriend(@person.id)
|
||||
user.friends.count.should == 0
|
||||
Person.all.count.should == 1
|
||||
end
|
||||
|
|
@ -67,21 +77,20 @@ describe Person do
|
|||
user_one.save
|
||||
user_two.save
|
||||
|
||||
person = Factory.create(:person)
|
||||
|
||||
user_one.friends << person
|
||||
user_two.friends << person
|
||||
user_one.friends << @person
|
||||
user_two.friends << @person
|
||||
user_one.save
|
||||
user_two.save
|
||||
|
||||
person.user_refs += 2
|
||||
person.save
|
||||
@person.user_refs += 2
|
||||
@person.save
|
||||
|
||||
Person.all.count.should == 3
|
||||
user_one.friends.count.should == 1
|
||||
user_two.friends.count.should == 1
|
||||
|
||||
user_one.unfriend(person.id)
|
||||
user_one.unfriend(@person.id)
|
||||
|
||||
user_one.friends.count.should == 0
|
||||
user_two.friends.count.should == 1
|
||||
|
|
|
|||
Loading…
Reference in a new issue