Class: Ci::PipelinePolicy

Inherits:
BasePolicy show all
Defined in:
app/policies/ci/pipeline_policy.rb

Direct Known Subclasses

PipelineSchedulePolicy

Instance Attribute Summary

Attributes inherited from DeclarativePolicy::Base

#subject, #user

Instance Method Summary collapse

Methods inherited from DeclarativePolicy::Base

ability_map, #allowed?, #banned?, #cache, #cached?, #can?, #condition, condition, conditions, configuration_for, #debug, delegate, #delegated_policies, delegations, desc, #disallowed?, enable_when, global_actions, #initialize, #inspect, last_options, last_options!, overrides, own_ability_map, own_conditions, own_delegations, own_global_actions, #policy_for, prevent_all_when, prevent_when, #repr, rule, #runner, with_options, with_scope, with_score

Constructor Details

This class inherits a constructor from DeclarativePolicy::Base

Instance Method Details

#ref_protected?(user, project, tag, ref) ⇒ Boolean

Returns:

  • (Boolean)

44
45
46
47
48
49
50
51
52
# File 'app/policies/ci/pipeline_policy.rb', line 44

def ref_protected?(user, project, tag, ref)
  access = ::Gitlab::UserAccess.new(user, container: project)

  if tag
    !access.can_create_tag?(ref)
  else
    !access.can_update_branch?(ref)
  end
end