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
|
|
|
|
|
|
|
|
end
|