Remove annoying deprecation warning from spec runs

Add spec for validation hook
This commit is contained in:
Sarah Mei 2010-09-26 10:00:29 -07:00
parent 64e1912c37
commit 0ec074be6d
2 changed files with 10 additions and 2 deletions

View file

@ -35,7 +35,7 @@ class User
after_create :seed_aspects after_create :seed_aspects
before_validation_on_create :downcase_username before_validation :downcase_username, :on => :create
def self.find_for_authentication(conditions={}) def self.find_for_authentication(conditions={})
if conditions[:username] =~ /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i # email regex if conditions[:username] =~ /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i # email regex

View file

@ -6,7 +6,14 @@ require 'spec_helper'
describe User do describe User do
let(:user) { Factory(:user) } let(:user) { Factory(:user) }
let(:aspect) { user.aspect(:name => 'heroes') }
describe "validations" do
it "downcases the username" do
user = Factory.build(:user, :username => "ALLUPPERCASE")
user.valid?
user.username.should == "alluppercase"
end
end
describe '#diaspora_handle' do describe '#diaspora_handle' do
it 'uses the pod config url to set the diaspora_handle' do it 'uses the pod config url to set the diaspora_handle' do
@ -27,6 +34,7 @@ describe User do
end end
context 'aspects' do context 'aspects' do
let(:aspect) { user.aspect(:name => 'heroes') }
let(:user2) { Factory(:user) } let(:user2) { Factory(:user) }
let(:aspect2) { user2.aspect(:name => 'stuff') } let(:aspect2) { user2.aspect(:name => 'stuff') }