Commit 8adb61e1 authored by pbair's avatar pbair

Add mixin to preserve model_name of CI models

Add a new mixin to CI models which did not extend the now-removed
Gitlab::Ci::Model, so the their `model_name` method is consistent
with the previous behavior.
parent 41c7cd79
......@@ -3,6 +3,7 @@
module Ci
class FreezePeriod < Ci::ApplicationRecord
include StripAttribute
include Ci::NamespacedModelName
default_scope { order(created_at: :asc) } # rubocop:disable Cop/DefaultScope
......
......@@ -2,6 +2,8 @@
module Ci
class PipelineChatData < Ci::ApplicationRecord
include Ci::NamespacedModelName
self.table_name = 'ci_pipeline_chat_data'
belongs_to :chat_name
......
......@@ -3,6 +3,8 @@
module Ci
module Sources
class Pipeline < Ci::ApplicationRecord
include Ci::NamespacedModelName
self.table_name = "ci_sources_pipelines"
belongs_to :project, class_name: "Project"
......
# frozen_string_literal: true
module Ci
module NamespacedModelName
extend ActiveSupport::Concern
class_methods do
def model_name
@model_name ||= ActiveModel::Name.new(self, Ci)
end
end
end
end
......@@ -8,6 +8,8 @@
module Ci
module Minutes
class AdditionalPack < Ci::ApplicationRecord
include Ci::NamespacedModelName
self.table_name = 'ci_minutes_additional_packs'
belongs_to :namespace
......
......@@ -5,6 +5,8 @@ module Ci
# Track usage of Shared Runners minutes at root namespace level.
# This class ensures that we keep 1 record per namespace per month.
class NamespaceMonthlyUsage < Ci::ApplicationRecord
include Ci::NamespacedModelName
belongs_to :namespace
scope :current_month, -> { where(date: beginning_of_month) }
......
......@@ -5,6 +5,8 @@ module Ci
# Track usage of Shared Runners minutes at root project level.
# This class ensures that we keep 1 record per project per month.
class ProjectMonthlyUsage < Ci::ApplicationRecord
include Ci::NamespacedModelName
belongs_to :project
scope :current_month, -> { where(date: beginning_of_month) }
......
......@@ -3,6 +3,8 @@
module Ci
module Sources
class Project < Ci::ApplicationRecord
include Ci::NamespacedModelName
self.table_name = "ci_sources_projects"
belongs_to :pipeline, class_name: "Ci::Pipeline", optional: false
......
......@@ -3,6 +3,7 @@
module Ci
module Subscriptions
class Project < Ci::ApplicationRecord
include Ci::NamespacedModelName
include ::Limitable
self.table_name = 'ci_subscriptions_projects'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment