Skip to content

Commit

Permalink
Remove annoying deprecation warning from spec runs
Browse files Browse the repository at this point in the history
Add spec for validation hook
  • Loading branch information
sarahmei committed Sep 26, 2010
1 parent 64e1912 commit 0ec074b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/user.rb
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion spec/models/user_spec.rb
Expand Up @@ -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
Expand All @@ -27,6 +34,7 @@
end

context 'aspects' do
let(:aspect) { user.aspect(:name => 'heroes') }
let(:user2) { Factory(:user) }
let(:aspect2) { user2.aspect(:name => 'stuff') }

Expand Down

0 comments on commit 0ec074b

Please sign in to comment.