Class: Subscriptions::Ci::Stages::JobsUpdated

Inherits:
BaseSubscription
  • Object
show all
Includes:
Gitlab::Graphql::Laziness
Defined in:
app/graphql/subscriptions/ci/stages/jobs_updated.rb

Constant Summary

Constants inherited from BaseSubscription

BaseSubscription::UNAUTHORIZED_ERROR_MESSAGE

Instance Method Summary collapse

Methods included from Gitlab::Graphql::Laziness

#defer, #force

Methods inherited from BaseSubscription

#initialize, #subscribe

Constructor Details

This class inherits a constructor from Subscriptions::BaseSubscription

Instance Method Details

#authorized?(stage_id:) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
# File 'app/graphql/subscriptions/ci/stages/jobs_updated.rb', line 15

def authorized?(stage_id:)
  stage = force(GitlabSchema.find_by_gid(stage_id))

  unauthorized! unless stage && Ability.allowed?(current_user, :read_build, stage.project)

  true
end

#update(stage_id:) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'app/graphql/subscriptions/ci/stages/jobs_updated.rb', line 23

def update(stage_id:)
  updated_job = object

  return NO_UPDATE unless updated_job

  # Verify the job actually belongs to this stage
  return NO_UPDATE unless updated_job.stage_id == stage_id.model_id.to_i

  updated_job
end