Commit 68aa88c9bdacc16b74b486062eea9cdd056fab16

Authored by Dmitriy Zaporozhets
1 parent 8bf8c70c

Fix project creation without import

Showing 1 changed file with 7 additions and 1 deletions   Show diff stats
app/models/project.rb
... ... @@ -76,7 +76,9 @@ class Project < ActiveRecord::Base
76 76 validates_uniqueness_of :name, scope: :namespace_id
77 77 validates_uniqueness_of :path, scope: :namespace_id
78 78  
79   - validates :import_url, format: { with: URI::regexp(%w(http https)), message: "should be a valid url" }
  79 + validates :import_url,
  80 + format: { with: URI::regexp(%w(http https)), message: "should be a valid url" },
  81 + if: :import?
80 82  
81 83 validate :check_limit, :repo_name
82 84  
... ... @@ -147,6 +149,10 @@ class Project < ActiveRecord::Base
147 149 id && valid?
148 150 end
149 151  
  152 + def import?
  153 + import_url.present?
  154 + end
  155 +
150 156 def check_limit
151 157 unless creator.can_create_project?
152 158 errors[:base] << ("Your own projects limit is #{creator.projects_limit}! Please contact administrator to increase it")
... ...