From 63d9373aa8722b69e7263f39af8e5194048b8b0d Mon Sep 17 00:00:00 2001 From: Cyril Date: Wed, 12 Dec 2012 17:53:43 +0100 Subject: [PATCH] Validates presence of User#name The 2 reasons are : - creation of user fail if name is empty : in after_save, it tries to create a namespace with namespace.name = user.name and namespece validates presence Namespace#name - in the web app links to team members are broken with empty User#name because they are of the form user.name --- app/models/user.rb | 1 + doc/api/users.md | 2 +- lib/api/users.rb | 2 -- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 3f2d7c92..f99fdd27 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -62,6 +62,7 @@ class User < ActiveRecord::Base has_many :assigned_issues, class_name: "Issue", foreign_key: :assignee_id, dependent: :destroy has_many :assigned_merge_requests, class_name: "MergeRequest", foreign_key: :assignee_id, dependent: :destroy + validates :name, presence: true validates :bio, length: { within: 0..255 } validates :extern_uid, allow_blank: true, uniqueness: {scope: :provider} validates :projects_limit, presence: true, numericality: {greater_than_or_equal_to: 0} diff --git a/doc/api/users.md b/doc/api/users.md index c116144d..e5674ab8 100644 --- a/doc/api/users.md +++ b/doc/api/users.md @@ -75,7 +75,7 @@ POST /users Parameters: + `email` (required) - Email + `password` (required) - Password -+ `name` - Name ++ `name` (required) - Name + `skype` - Skype ID + `linkedin` - Linkedin + `twitter` - Twitter account diff --git a/lib/api/users.rb b/lib/api/users.rb index cad99fd9..140c20f6 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -101,8 +101,6 @@ module Gitlab key = current_user.keys.find params[:id] key.delete end - - end end end