Permalink
Browse files

Remove annoying deprecation warning from spec runs

Add spec for validation hook
  • Loading branch information...
sarahmei committed Sep 26, 2010
1 parent 64e1912 commit 0ec074be6d1ba626ea4814b4d06091b7a2f0d51f
Showing with 10 additions and 2 deletions.
  1. +1 −1 app/models/user.rb
  2. +9 −1 spec/models/user_spec.rb
View
@@ -35,7 +35,7 @@ class User
after_create :seed_aspects
- before_validation_on_create :downcase_username
+ before_validation :downcase_username, :on => :create
def self.find_for_authentication(conditions={})
if conditions[:username] =~ /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i # email regex
View
@@ -6,7 +6,14 @@
describe User do
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
it 'uses the pod config url to set the diaspora_handle' do
@@ -27,6 +34,7 @@
end
context 'aspects' do
+ let(:aspect) { user.aspect(:name => 'heroes') }
let(:user2) { Factory(:user) }
let(:aspect2) { user2.aspect(:name => 'stuff') }

0 comments on commit 0ec074b

Please sign in to comment.