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 @@ ...@@ -3,6 +3,7 @@
module Ci module Ci
class FreezePeriod < Ci::ApplicationRecord class FreezePeriod < Ci::ApplicationRecord
include StripAttribute include StripAttribute
include Ci::NamespacedModelName
default_scope { order(created_at: :asc) } # rubocop:disable Cop/DefaultScope default_scope { order(created_at: :asc) } # rubocop:disable Cop/DefaultScope
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
module Ci module Ci
class PipelineChatData < Ci::ApplicationRecord class PipelineChatData < Ci::ApplicationRecord
include Ci::NamespacedModelName
self.table_name = 'ci_pipeline_chat_data' self.table_name = 'ci_pipeline_chat_data'
belongs_to :chat_name belongs_to :chat_name
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
module Ci module Ci
module Sources module Sources
class Pipeline < Ci::ApplicationRecord class Pipeline < Ci::ApplicationRecord
include Ci::NamespacedModelName
self.table_name = "ci_sources_pipelines" self.table_name = "ci_sources_pipelines"
belongs_to :project, class_name: "Project" 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 @@ ...@@ -8,6 +8,8 @@
module Ci module Ci
module Minutes module Minutes
class AdditionalPack < Ci::ApplicationRecord class AdditionalPack < Ci::ApplicationRecord
include Ci::NamespacedModelName
self.table_name = 'ci_minutes_additional_packs' self.table_name = 'ci_minutes_additional_packs'
belongs_to :namespace belongs_to :namespace
......
...@@ -5,6 +5,8 @@ module Ci ...@@ -5,6 +5,8 @@ module Ci
# Track usage of Shared Runners minutes at root namespace level. # Track usage of Shared Runners minutes at root namespace level.
# This class ensures that we keep 1 record per namespace per month. # This class ensures that we keep 1 record per namespace per month.
class NamespaceMonthlyUsage < Ci::ApplicationRecord class NamespaceMonthlyUsage < Ci::ApplicationRecord
include Ci::NamespacedModelName
belongs_to :namespace belongs_to :namespace
scope :current_month, -> { where(date: beginning_of_month) } scope :current_month, -> { where(date: beginning_of_month) }
......
...@@ -5,6 +5,8 @@ module Ci ...@@ -5,6 +5,8 @@ module Ci
# Track usage of Shared Runners minutes at root project level. # Track usage of Shared Runners minutes at root project level.
# This class ensures that we keep 1 record per project per month. # This class ensures that we keep 1 record per project per month.
class ProjectMonthlyUsage < Ci::ApplicationRecord class ProjectMonthlyUsage < Ci::ApplicationRecord
include Ci::NamespacedModelName
belongs_to :project belongs_to :project
scope :current_month, -> { where(date: beginning_of_month) } scope :current_month, -> { where(date: beginning_of_month) }
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
module Ci module Ci
module Sources module Sources
class Project < Ci::ApplicationRecord class Project < Ci::ApplicationRecord
include Ci::NamespacedModelName
self.table_name = "ci_sources_projects" self.table_name = "ci_sources_projects"
belongs_to :pipeline, class_name: "Ci::Pipeline", optional: false belongs_to :pipeline, class_name: "Ci::Pipeline", optional: false
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
module Ci module Ci
module Subscriptions module Subscriptions
class Project < Ci::ApplicationRecord class Project < Ci::ApplicationRecord
include Ci::NamespacedModelName
include ::Limitable include ::Limitable
self.table_name = 'ci_subscriptions_projects' 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