Read about our upcoming Code of Conduct on this issue

Commit 035196e7 authored by gitlabhq's avatar gitlabhq
Browse files

test fix

parent 6476e5cddd08
......@@ -35,6 +35,7 @@ def edit
def create
@admin_project = Project.new(params[:project])
@admin_project.owner = current_user
respond_to do |format|
if @admin_project.save
......
require "grit"
class Project < ActiveRecord::Base
belongs_to :owner, :class_name => "User"
has_many :issues, :dependent => :destroy
has_many :users_projects, :dependent => :destroy
has_many :users, :through => :users_projects
belongs_to :owner, :class_name => "User"
has_many :notes, :dependent => :destroy
validates :name,
......@@ -25,6 +26,9 @@ class Project < ActiveRecord::Base
:uniqueness => true,
:length => { :within => 3..12 }
validates :owner,
:presence => true
validate :check_limit
before_save :format_code
......@@ -130,8 +134,10 @@ def tree(fcommit, path = nil)
def check_limit
unless owner.can_create_project?
errors[:base] << ("You can to have #{owner.projects_limit} your own projects")
errors[:base] << ("Your own projects limit is #{owner.projects_limit}! Please contact administrator to increase it")
end
rescue
errors[:base] << ("Cant check your ability to create project")
end
def valid_repo?
......
......@@ -70,7 +70,7 @@
t.datetime "updated_at"
t.string "name"
t.boolean "admin", :default => false, :null => false
t.integer "projects_limit"
t.integer "projects_limit", :default => 10
end
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
......
......@@ -3,6 +3,7 @@
Factory.add(:project, Project) do |obj|
obj.name = Faker::Internet.user_name
obj.path = 'legit'
obj.owner = Factory(:user)
obj.code = 'LGT'
end
......@@ -10,6 +11,7 @@
obj.name = Faker::Internet.user_name
obj.path = 'legit'
obj.private_flag = false
obj.owner = Factory(:user)
obj.code = 'LGT'
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment