summaryrefslogtreecommitdiff
path: root/app/models/member.rb
diff options
context:
space:
mode:
authorJames Lopez <james.lopez@vodafone.com>2015-11-11 15:42:27 +0000
committerJames Lopez <james.lopez@vodafone.com>2015-11-11 15:42:27 +0000
commitc6a0f109cd393e951f4d700b06490d819e6792ba (patch)
treeec1f42eb32ef8a8e8a047ba2b2788eea020c05d0 /app/models/member.rb
parent1b14bc59570a625365fef232f8c57919f76b3e2a (diff)
downloadgitlab-ce-c6a0f109cd393e951f4d700b06490d819e6792ba.tar.gz
refactored code as projects only have one owner. Kept some refactoring in place (has_owners concern)
Diffstat (limited to 'app/models/member.rb')
-rw-r--r--app/models/member.rb13
1 files changed, 6 insertions, 7 deletions
diff --git a/app/models/member.rb b/app/models/member.rb
index c565ee6bbce..30160c813e1 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -30,13 +30,13 @@ class Member < ActiveRecord::Base
validates :user, presence: true, unless: :invite?
validates :source, presence: true
- validates :user_id, uniqueness: { scope: [:source_type, :source_id],
+ validates :user_id, uniqueness: { scope: [:source_type, :source_id],
message: "already exists in source",
allow_nil: true }
validates :access_level, inclusion: { in: Gitlab::Access.all_values }, presence: true
- validates :invite_email, presence: { if: :invite? },
- email: { strict_mode: true, allow_nil: true },
- uniqueness: { scope: [:source_type, :source_id], allow_nil: true }
+ validates :invite_email, presence: { if: :invite? },
+ email: { strict_mode: true, allow_nil: true },
+ uniqueness: { scope: [:source_type, :source_id], allow_nil: true }
scope :invite, -> { where(user_id: nil) }
scope :non_invite, -> { where("user_id IS NOT NULL") }
@@ -94,8 +94,7 @@ class Member < ActiveRecord::Base
def can_update_member?(current_user, member)
!current_user || current_user.can?(:update_group_member, member) ||
- (member.respond_to?(:project) &&
- current_user.can?(:update_project_member, member))
+ current_user.can?(:update_project_member, member)
end
end
@@ -105,7 +104,7 @@ class Member < ActiveRecord::Base
def accept_invite!(new_user)
return false unless invite?
-
+
self.invite_token = nil
self.invite_accepted_at = Time.now.utc