0
@@ -5,100 +5,94 @@ require File.dirname(__FILE__) + '/../spec_helper'
0
include AuthenticatedTestHelper
0
- describe 'being created' do
0
- @creating_person = lambda do
0
- @person = create_person
0
- violated "#{@person.errors.full_messages.to_sentence}" if @person.new_record?
0
- it 'increments User#count' do
0
- @creating_person.should change(Person, :count).by(1)
0
+ @person = people(:quentin)
0
+ it "should be valid" do
0
+ create_person.should be_valid
0
it 'requires password' do
0
- u = create_person(:password => nil)
0
- u.errors.on(:password).should_not be_nil
0
- end.should_not change(Person, :count)
0
+ u = create_person(:password => nil)
0
+ u.errors.on(:password).should_not be_nil
0
it 'requires password confirmation' do
0
- u = create_person(:password_confirmation => nil)
0
- u.errors.on(:password_confirmation).should_not be_nil
0
- end.should_not change(Person, :count)
0
+ u = create_person(:password_confirmation => nil)
0
+ u.errors.on(:password_confirmation).should_not be_nil
0
- u = create_person(:email => nil)
0
- u.errors.on(:email).should_not be_nil
0
- end.should_not change(Person, :count)
0
+ u = create_person(:email => nil)
0
+ u.errors.on(:email).should_not be_nil
0
it 'resets password' do
0
- people(:quentin).update_attributes(:password => 'new password', :password_confirmation => 'new password')
0
- Person.authenticate('quentin@example.com', 'new password').should == people(:quentin)
0
+ @person.update_attributes(:password => 'newp',
0
+ :password_confirmation => 'newp')
0
+ Person.authenticate('quentin@example.com', 'newp').should == @person
0
it 'does not rehash password' do
0
- people(:quentin).update_attributes(:email => 'quentin2@example.com')
0
- Person.authenticate('quentin2@example.com', 'test').should == people(:quentin)
0
+ @person.update_attributes(:email => 'quentin2@example.com')
0
+ Person.authenticate('quentin2@example.com', 'test').should == @person
0
it 'authenticates person' do
0
- Person.authenticate('queNTin@eXample.com', 'test').should == people(:quentin)
0
+ Person.authenticate('quentin@example.com', 'test').should == @person
0
+ it "should authenticate case-insensitively" do
0
+ Person.authenticate('queNTin@eXample.com', 'test').should == @person
0
it 'sets remember token' do
0
- people(:quentin).remember_me
0
- people(:quentin).remember_token.should_not be_nil
0
- people(:quentin).remember_token_expires_at.should_not be_nil
0
+ @person.remember_token.should_not be_nil
0
+ @person.remember_token_expires_at.should_not be_nil
0
it 'unsets remember token' do
0
- people(:quentin).remember_me
0
- people(:quentin).remember_token.should_not be_nil
0
- people(:quentin).forget_me
0
- people(:quentin).remember_token.should be_nil
0
+ @person.remember_token.should_not be_nil
0
+ @person.remember_token.should be_nil
0
it 'remembers me for one week' do
0
before = 1.week.from_now.utc
0
-
people(:quentin).remember_me_for 1.week
0
+
@person.remember_me_for 1.week
0
after = 1.week.from_now.utc
0
- people(:quentin).remember_token.should_not be_nil
0
- people(:quentin).remember_token_expires_at.should_not be_nil
0
- people(:quentin).remember_token_expires_at.between?(before, after).should be_true
0
+ @person.remember_token.should_not be_nil
0
+ @person.remember_token_expires_at.should_not be_nil
0
+ @person.remember_token_expires_at.between?(before, after).should be_true
0
it 'remembers me until one week' do
0
time = 1.week.from_now.utc
0
- people(:quentin).remember_me_until time
0
- people(:quentin).remember_token.should_not be_nil
0
- people(:quentin).remember_token_expires_at.should_not be_nil
0
- people(:quentin).remember_token_expires_at.should == time
0
+ @person.remember_me_until time
0
+ @person.remember_token.should_not be_nil
0
+ @person.remember_token_expires_at.should_not be_nil
0
+ @person.remember_token_expires_at.should == time
0
it 'remembers me default two weeks' do
0
before = 2.weeks.from_now.utc
0
-
people(:quentin).remember_me
0
after = 2.weeks.from_now.utc
0
- people(:quentin).remember_token.should_not be_nil
0
- people(:quentin).remember_token_expires_at.should_not be_nil
0
- people(:quentin).remember_token_expires_at.between?(before, after).should be_true
0
+ @person.remember_token.should_not be_nil
0
+ @person.remember_token_expires_at.should_not be_nil
0
+ @person.remember_token_expires_at.between?(before, after).should be_true
0
def create_person(options = {})
0
- record = Person.new({ :email => 'quire@example.com', :password => 'quire', :password_confirmation => 'quire' }.merge(options))
0
+ record = Person.new({ :email => 'quire@example.com',
0
+ :password_confirmation => 'quire' }.merge(options))
Comments
No one has commented yet.