Commit 68aa88c9bdacc16b74b486062eea9cdd056fab16
1 parent
8bf8c70c
Exists in
master
and in
4 other branches
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,7 +76,9 @@ class Project < ActiveRecord::Base | ||
| 76 | validates_uniqueness_of :name, scope: :namespace_id | 76 | validates_uniqueness_of :name, scope: :namespace_id |
| 77 | validates_uniqueness_of :path, scope: :namespace_id | 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 | validate :check_limit, :repo_name | 83 | validate :check_limit, :repo_name |
| 82 | 84 | ||
| @@ -147,6 +149,10 @@ class Project < ActiveRecord::Base | @@ -147,6 +149,10 @@ class Project < ActiveRecord::Base | ||
| 147 | id && valid? | 149 | id && valid? |
| 148 | end | 150 | end |
| 149 | 151 | ||
| 152 | + def import? | ||
| 153 | + import_url.present? | ||
| 154 | + end | ||
| 155 | + | ||
| 150 | def check_limit | 156 | def check_limit |
| 151 | unless creator.can_create_project? | 157 | unless creator.can_create_project? |
| 152 | errors[:base] << ("Your own projects limit is #{creator.projects_limit}! Please contact administrator to increase it") | 158 | errors[:base] << ("Your own projects limit is #{creator.projects_limit}! Please contact administrator to increase it") |