Merge pull request #51 from opf/feature/longer_logins

migrate longer logins plugin to core
pull/52/merge
cratz 12 years ago
commit 1a0aca08dc
  1. 2
      app/models/user.rb
  2. 13
      db/migrate/20130315124655_add_longer_login_to_users.rb
  3. 35
      spec/models/user_spec.rb

@ -99,7 +99,7 @@ class User < Principal
validates_uniqueness_of :mail, :allow_blank => true, :case_sensitive => false validates_uniqueness_of :mail, :allow_blank => true, :case_sensitive => false
# Login must contain lettres, numbers, underscores only # Login must contain lettres, numbers, underscores only
validates_format_of :login, :with => /^[a-z0-9_\-@\.]*$/i validates_format_of :login, :with => /^[a-z0-9_\-@\.]*$/i
validates_length_of :login, :maximum => 30 validates_length_of :login, :maximum => 256
validates_length_of :firstname, :lastname, :maximum => 30 validates_length_of :firstname, :lastname, :maximum => 30
validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :allow_blank => true validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :allow_blank => true
validates_length_of :mail, :maximum => 60, :allow_nil => true validates_length_of :mail, :maximum => 60, :allow_nil => true

@ -0,0 +1,13 @@
class AddLongerLoginToUsers < ActiveRecord::Migration
def self.up
change_table :users do |t|
t.change "login", :string, :limit => 256, :default => "", :null => false
end
end
def self.down
change_table :users do |t|
t.change "login", :string, :limit => 30, :default => "", :null => false
end
end
end

@ -13,6 +13,41 @@ describe User do
:project => project, :project => project,
:status => issue_status) } :status => issue_status) }
describe 'a user with a long login (<= 256 chars)' do
it 'is valid' do
user.login = 'a' * 256
user.should be_valid
end
it 'may be stored in the database' do
user.login = 'a' * 256
user.save.should be_true
end
it 'may be loaded from the database' do
user.login = 'a' * 256
user.save
User.find_by_login('a' * 256).should == user
end
end
describe 'a user with and overly long login (> 256 chars)' do
it 'is invalid' do
user.login = 'a' * 257
user.should_not be_valid
end
it 'may not be stored in the database' do
user.login = 'a' * 257
user.save.should be_false
end
end
describe :assigned_issues do describe :assigned_issues do
before do before do
user.save! user.save!

Loading…
Cancel
Save