Commit 0f0c562de09e325c5689b3db8e646b68322f5515
1 parent
59704f48
Exists in
master
and in
4 other branches
Add check to ensure that a team member has atleast one Access Role selected
Showing
1 changed file
with
6 additions
and
1 deletions
Show diff stats
app/models/users_project.rb
| ... | ... | @@ -9,7 +9,8 @@ class UsersProject < ActiveRecord::Base |
| 9 | 9 | validates_uniqueness_of :user_id, :scope => [:project_id] |
| 10 | 10 | validates_presence_of :user_id |
| 11 | 11 | validates_presence_of :project_id |
| 12 | - | |
| 12 | + validate :user_has_a_role_selected | |
| 13 | + | |
| 13 | 14 | delegate :name, :email, :to => :user, :prefix => true |
| 14 | 15 | |
| 15 | 16 | def update_gitosis_project |
| ... | ... | @@ -18,6 +19,10 @@ class UsersProject < ActiveRecord::Base |
| 18 | 19 | end |
| 19 | 20 | end |
| 20 | 21 | |
| 22 | + def user_has_a_role_selected | |
| 23 | + errors.add(:base, "Please choose at least one Role in the Access list") unless read || write || admin | |
| 24 | + end | |
| 25 | + | |
| 21 | 26 | end |
| 22 | 27 | # == Schema Information |
| 23 | 28 | # | ... | ... |