Skip to content

Commit

Permalink
Minimum length for project and org is now 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Villalba committed Oct 9, 2011
1 parent da53c9e commit 87de263
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/models/organization.rb
Expand Up @@ -18,7 +18,7 @@ class Organization < ActiveRecord::Base
validates_presence_of :permalink
validates_uniqueness_of :permalink, :case_sensitive => false, :scope => :deleted
validates_uniqueness_of :domain, :case_sensitive => false, :allow_nil => true, :allow_blank => true, :scope => :deleted
validates_length_of :permalink, :minimum => 4
validates_length_of :permalink, :minimum => 2
validates_exclusion_of :permalink, :in => %w(www help support mail pop smtp ftp guide)
validates_format_of :permalink, :with => /^[\w\_\-]+$/

Expand Down
4 changes: 2 additions & 2 deletions app/models/project/permalink.rb
@@ -1,11 +1,11 @@
class Project

include GrabName
has_permalink :name, :min_length => 5
has_permalink :name, :min_length => 2

def self.grab_name_by_permalink(permalink)
p = self.find_by_permalink(permalink,:select => 'name')
p.try(:name) || ''
end

end
end
8 changes: 4 additions & 4 deletions app/models/project/validation.rb
Expand Up @@ -3,15 +3,15 @@ class Project
validates_length_of :name, :minimum => 1, :on => :create
validates_length_of :name, :minimum => 1, :on => :update
validates_uniqueness_of :permalink, :case_sensitive => false, :scope => :deleted
validates_length_of :permalink, :minimum => 5
validates_format_of :permalink, :with => /^[a-z0-9_\-]{5,}$/, :if => :permalink_length_valid?
validates_length_of :permalink, :minimum => 2
validates_format_of :permalink, :with => /^[a-z0-9_\-]{2,}$/, :if => :permalink_length_valid?

# needs an owner
validates_presence_of :user # A project _needs_ an owner
validates_presence_of :organization

def permalink_length_valid?
permalink.length >= 5
permalink.length >= 2
end

def ensure_organization
Expand All @@ -20,4 +20,4 @@ def ensure_organization
end
end

end
end

0 comments on commit 87de263

Please sign in to comment.