2015-03-18 22:02:38 +00:00
|
|
|
class PullRequestPolicy < ApplicationPolicy
|
|
|
|
|
2015-04-01 01:47:32 +01:00
|
|
|
def index?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2015-03-18 22:02:38 +00:00
|
|
|
def show?
|
2015-04-06 23:35:48 +01:00
|
|
|
is_admin? || ProjectPolicy.new(user, record.to_project).show?
|
2015-03-18 22:02:38 +00:00
|
|
|
end
|
|
|
|
alias_method :read?, :show?
|
|
|
|
alias_method :commits?, :show?
|
|
|
|
alias_method :files?, :show?
|
2015-04-13 21:46:04 +01:00
|
|
|
alias_method :create?, :show?
|
2015-03-18 22:02:38 +00:00
|
|
|
|
|
|
|
def update?
|
2015-04-13 21:46:04 +01:00
|
|
|
return false if user.guest?
|
|
|
|
is_admin? || record.user_id == user.id || local_writer?(record.to_project)
|
2015-03-18 22:02:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def merge?
|
2015-04-13 21:46:04 +01:00
|
|
|
return false if user.guest?
|
2015-04-06 23:35:48 +01:00
|
|
|
is_admin? || local_writer?(record.to_project)
|
2015-03-18 22:02:38 +00:00
|
|
|
end
|
|
|
|
|
2015-05-19 22:21:13 +01:00
|
|
|
# Public: Get list of parameters that the user is allowed to alter.
|
|
|
|
#
|
|
|
|
# Returns Array
|
|
|
|
def permitted_attributes
|
|
|
|
%i(
|
|
|
|
body
|
|
|
|
from_ref
|
|
|
|
title
|
|
|
|
to_ref
|
2015-05-22 21:19:07 +01:00
|
|
|
) + [ issue_attributes: %i(title body) ]
|
2015-05-19 22:21:13 +01:00
|
|
|
end
|
|
|
|
|
2015-03-18 22:02:38 +00:00
|
|
|
end
|