From 0ec074be6d1ba626ea4814b4d06091b7a2f0d51f Mon Sep 17 00:00:00 2001 From: Sarah Mei <sarahmei@gmail.com> Date: Sun, 26 Sep 2010 10:00:29 -0700 Subject: [PATCH] Remove annoying deprecation warning from spec runs Add spec for validation hook --- app/models/user.rb | 2 +- spec/models/user_spec.rb | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index ade7b7a2a8..1e062b0c83 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index ad7070eaaf..46327576a8 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -6,7 +6,14 @@ require 'spec_helper' 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 @@ describe User do end context 'aspects' do + let(:aspect) { user.aspect(:name => 'heroes') } let(:user2) { Factory(:user) } let(:aspect2) { user2.aspect(:name => 'stuff') } -- GitLab