Commit c1dddf8c7d947691729f6d64a8ea768b5c915855

Authored by Marin Jankovski
1 parent 499a1185

Uniqueness check should be case insensitive for username and path, otherwise mysql behaves weird.

Showing 2 changed files with 2 additions and 2 deletions   Show diff stats
app/models/namespace.rb
@@ -27,7 +27,7 @@ class Namespace < ActiveRecord::Base @@ -27,7 +27,7 @@ class Namespace < ActiveRecord::Base
27 format: { with: Gitlab::Regex.name_regex, 27 format: { with: Gitlab::Regex.name_regex,
28 message: "only letters, digits, spaces & '_' '-' '.' allowed." } 28 message: "only letters, digits, spaces & '_' '-' '.' allowed." }
29 validates :description, length: { within: 0..255 } 29 validates :description, length: { within: 0..255 }
30 - validates :path, uniqueness: true, presence: true, length: { within: 1..255 }, 30 + validates :path, uniqueness: { case_sensitive: false }, presence: true, length: { within: 1..255 },
31 exclusion: { in: Gitlab::Blacklist.path }, 31 exclusion: { in: Gitlab::Blacklist.path },
32 format: { with: Gitlab::Regex.path_regex, 32 format: { with: Gitlab::Regex.path_regex,
33 message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } 33 message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" }
app/models/user.rb
@@ -109,7 +109,7 @@ class User < ActiveRecord::Base @@ -109,7 +109,7 @@ class User < ActiveRecord::Base
109 validates :bio, length: { maximum: 255 }, allow_blank: true 109 validates :bio, length: { maximum: 255 }, allow_blank: true
110 validates :extern_uid, allow_blank: true, uniqueness: {scope: :provider} 110 validates :extern_uid, allow_blank: true, uniqueness: {scope: :provider}
111 validates :projects_limit, presence: true, numericality: {greater_than_or_equal_to: 0} 111 validates :projects_limit, presence: true, numericality: {greater_than_or_equal_to: 0}
112 - validates :username, presence: true, uniqueness: true, 112 + validates :username, presence: true, uniqueness: { case_sensitive: false },
113 exclusion: { in: Gitlab::Blacklist.path }, 113 exclusion: { in: Gitlab::Blacklist.path },
114 format: { with: Gitlab::Regex.username_regex, 114 format: { with: Gitlab::Regex.username_regex,
115 message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } 115 message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" }