simple refactoring
This commit is contained in:
parent
a635b9da97
commit
df7c52489a
21 changed files with 276 additions and 264 deletions
|
@ -41,7 +41,7 @@ module Account
|
|||
# Remove user from all projects and
|
||||
# set blocked attribute to true
|
||||
def block
|
||||
users_projects.all.each do |membership|
|
||||
users_projects.find_each do |membership|
|
||||
return false unless membership.destroy
|
||||
end
|
||||
|
||||
|
|
|
@ -2,12 +2,12 @@ module Authority
|
|||
# Compatible with all access rights
|
||||
# Should be rewrited for new access rights
|
||||
def add_access(user, *access)
|
||||
access = if access.include?(:admin)
|
||||
{ project_access: UsersProject::MASTER }
|
||||
access = if access.include?(:admin)
|
||||
{ project_access: UsersProject::MASTER }
|
||||
elsif access.include?(:write)
|
||||
{ project_access: UsersProject::DEVELOPER }
|
||||
{ project_access: UsersProject::DEVELOPER }
|
||||
else
|
||||
{ project_access: UsersProject::REPORTER }
|
||||
{ project_access: UsersProject::REPORTER }
|
||||
end
|
||||
opts = { user: user }
|
||||
opts.merge!(access)
|
||||
|
|
|
@ -8,12 +8,9 @@ module IssueCommonality
|
|||
belongs_to :assignee, class_name: "User"
|
||||
has_many :notes, as: :noteable, dependent: :destroy
|
||||
|
||||
validates_presence_of :project_id
|
||||
validates_presence_of :author_id
|
||||
|
||||
validates :title,
|
||||
presence: true,
|
||||
length: { within: 0..255 }
|
||||
validates :project, presence: true
|
||||
validates :author, presence: true
|
||||
validates :title, presence: true, length: { within: 0..255 }
|
||||
validates :closed, inclusion: { in: [true, false] }
|
||||
|
||||
scope :opened, where(closed: false)
|
||||
|
|
|
@ -5,11 +5,11 @@ module PushEvent
|
|||
false
|
||||
end
|
||||
|
||||
def tag?
|
||||
def tag?
|
||||
data[:ref]["refs/tags"]
|
||||
end
|
||||
|
||||
def branch?
|
||||
def branch?
|
||||
data[:ref]["refs/heads"]
|
||||
end
|
||||
|
||||
|
@ -25,7 +25,7 @@ module PushEvent
|
|||
commit_to =~ /^00000/
|
||||
end
|
||||
|
||||
def md_ref?
|
||||
def md_ref?
|
||||
!(rm_ref? || new_ref?)
|
||||
end
|
||||
|
||||
|
@ -37,7 +37,7 @@ module PushEvent
|
|||
data[:after]
|
||||
end
|
||||
|
||||
def ref_name
|
||||
def ref_name
|
||||
if tag?
|
||||
tag_name
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue