Skip to content

Commit

Permalink
Logins can have caps in them now.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Bleigh committed Mar 21, 2009
1 parent 10307e4 commit 3323a3f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/twitter_auth/generic_user.rb
Expand Up @@ -23,9 +23,9 @@ class GenericUser < ActiveRecord::Base
]

validates_presence_of :login
validates_format_of :login, :with => /\A[a-z0-9_]+\z/
validates_format_of :login, :with => /\A[a-z0-9_]+\z/i
validates_length_of :login, :in => 1..15
validates_uniqueness_of :login
validates_uniqueness_of :login, :case_sensitive => false

def self.table_name; 'users' end

Expand Down
9 changes: 9 additions & 0 deletions spec/models/twitter_auth/generic_user_spec.rb
Expand Up @@ -11,6 +11,15 @@
Factory.build(:twitter_oauth_user).should have_at_least(1).errors_on(:login)
end

it 'should allow capital letters in the username' do
Factory.build(:twitter_oauth_user, :login => 'TwitterMan').should have(:no).errors_on(:login)
end

it 'should not allow the same login with different capitalization' do
Factory.create(:twitter_oauth_user, :login => 'twitterman')
Factory.build(:twitter_oauth_user, :login => 'TwitterMan').should have_at_least(1).errors_on(:login)
end

describe '.new_from_twitter_hash' do
it 'should raise an argument error if the hash does not have a screen_name attribute' do
lambda{User.new_from_twitter_hash({})}.should raise_error(ArgumentError, 'Invalid hash: must include screen_name.')
Expand Down

0 comments on commit 3323a3f

Please sign in to comment.