1b388c798b
Create new entity called TriggerVariablesEnitity for trigger variables, to aid reuseablity in the future. Update JSON schema to include trigger information in the response. Refactor rspec tests a bit to reduce duplication and for the `context` to make sense. closes https://gitlab.com/gitlab-org/gitlab-ce/issues/50989
27 lines
699 B
Ruby
27 lines
699 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Ci
|
|
class TriggerRequest < ActiveRecord::Base
|
|
extend Gitlab::Ci::Model
|
|
|
|
belongs_to :trigger
|
|
belongs_to :pipeline, foreign_key: :commit_id
|
|
has_many :builds
|
|
|
|
delegate :short_token, to: :trigger, prefix: true, allow_nil: true
|
|
|
|
# We switched to Ci::PipelineVariable from Ci::TriggerRequest.variables.
|
|
# Ci::TriggerRequest doesn't save variables anymore.
|
|
validates :variables, absence: true
|
|
|
|
serialize :variables # rubocop:disable Cop/ActiveRecordSerialize
|
|
|
|
def user_variables
|
|
return [] unless variables
|
|
|
|
variables.map do |key, value|
|
|
{ key: key, value: value, public: false }
|
|
end
|
|
end
|
|
end
|
|
end
|