Commit c66c30c821a77309302560667692854b2caabb8d
1 parent
c7ccfb9a
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,7 +9,8 @@ class UsersProject < ActiveRecord::Base | ||
9 | validates_uniqueness_of :user_id, :scope => [:project_id] | 9 | validates_uniqueness_of :user_id, :scope => [:project_id] |
10 | validates_presence_of :user_id | 10 | validates_presence_of :user_id |
11 | validates_presence_of :project_id | 11 | validates_presence_of :project_id |
12 | - | 12 | + validate :user_has_a_role_selected |
13 | + | ||
13 | delegate :name, :email, :to => :user, :prefix => true | 14 | delegate :name, :email, :to => :user, :prefix => true |
14 | 15 | ||
15 | def update_gitosis_project | 16 | def update_gitosis_project |
@@ -18,6 +19,10 @@ class UsersProject < ActiveRecord::Base | @@ -18,6 +19,10 @@ class UsersProject < ActiveRecord::Base | ||
18 | end | 19 | end |
19 | end | 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 | end | 26 | end |
22 | # == Schema Information | 27 | # == Schema Information |
23 | # | 28 | # |