Skip to content

Commit

Permalink
Merge pull request #96 from gabceb/master
Browse files Browse the repository at this point in the history
Uniqueness and presence added to user's username
  • Loading branch information
fusion94 committed Feb 20, 2013
2 parents 1b1ec67 + 5fcd900 commit b961af3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/user.rb
Expand Up @@ -3,6 +3,8 @@ class User < ActiveRecord::Base
has_many :activities
before_save :ensure_authentication_token
before_save :ensure_gravatar_hash

validates :username, :presence => true, :uniqueness => true


# Kandan.devise_modules is defined in config/initializers/kandan.rb
Expand Down
5 changes: 5 additions & 0 deletions spec/factories.rb
Expand Up @@ -11,6 +11,10 @@
"#{rand(11111111...99999999)}"
end

sequence :username do |n|
"user#{n}"
end

factory :channel do |f|
f.name "Test channel"
end
Expand All @@ -21,5 +25,6 @@
f.password { FactoryGirl.generate(:password)}
f.email { FactoryGirl.generate(:email) }
f.ido_id { FactoryGirl.generate(:ido_id) }
f.username { FactoryGirl.generate(:username) }
end
end

0 comments on commit b961af3

Please sign in to comment.