Commit a36195bd2853bfef1b6883eef64334767e12fcf1
1 parent
34c97a31
Exists in
master
and in
4 other branches
Validate project limit only when create project
Showing
2 changed files
with
7 additions
and
4 deletions
Show diff stats
app/contexts/projects/create_context.rb
... | ... | @@ -46,11 +46,14 @@ module Projects |
46 | 46 | @project.creator = current_user |
47 | 47 | |
48 | 48 | if @project.save |
49 | + @project.discover_default_branch | |
50 | + | |
49 | 51 | unless @project.group |
50 | - @project.users_projects.create(project_access: UsersProject::MASTER, user: current_user) | |
52 | + @project.users_projects.create( | |
53 | + project_access: UsersProject::MASTER, | |
54 | + user: current_user | |
55 | + ) | |
51 | 56 | end |
52 | - | |
53 | - @project.discover_default_branch | |
54 | 57 | end |
55 | 58 | |
56 | 59 | @project | ... | ... |
app/models/project.rb
... | ... | @@ -89,7 +89,7 @@ class Project < ActiveRecord::Base |
89 | 89 | format: { with: URI::regexp(%w(git http https)), message: "should be a valid url" }, |
90 | 90 | if: :import? |
91 | 91 | |
92 | - validate :check_limit | |
92 | + validate :check_limit, on: :create | |
93 | 93 | |
94 | 94 | # Scopes |
95 | 95 | scope :without_user, ->(user) { where("projects.id NOT IN (:ids)", ids: user.authorized_projects.map(&:id) ) } | ... | ... |