Remove annoying deprecation warning from spec runs
Add spec for validation hook
This commit is contained in:
parent
64e1912c37
commit
0ec074be6d
2 changed files with 10 additions and 2 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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') }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue