summaryrefslogtreecommitdiff
path: root/app/models/service.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-11 18:08:58 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-11 18:08:58 +0000
commit1ca9950d5f890cd8f185e1eda158b969a7244fe2 (patch)
tree6f62715938a4b2b001705c51c697609a8e0850ae /app/models/service.rb
parentbcc77054ee9aefd1e332e04a4189390fd5a3112e (diff)
downloadgitlab-ce-1ca9950d5f890cd8f185e1eda158b969a7244fe2.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/service.rb')
-rw-r--r--app/models/service.rb20
1 files changed, 12 insertions, 8 deletions
diff --git a/app/models/service.rb b/app/models/service.rb
index 6d0e375e757..95b7c6927cf 100644
--- a/app/models/service.rb
+++ b/app/models/service.rb
@@ -32,7 +32,7 @@ class Service < ApplicationRecord
belongs_to :project, inverse_of: :services
has_one :service_hook
- validates :project_id, presence: true, unless: proc { |service| service.instance? }
+ validates :project_id, presence: true, unless: proc { |service| service.template? }
validates :type, presence: true
scope :visible, -> { where.not(type: 'GitlabIssueTrackerService') }
@@ -70,8 +70,8 @@ class Service < ApplicationRecord
true
end
- def instance?
- instance
+ def template?
+ template
end
def category
@@ -299,15 +299,15 @@ class Service < ApplicationRecord
service_names.sort_by(&:downcase)
end
- def self.build_from_instance(project_id, instance_level_service)
- service = instance_level_service.dup
+ def self.build_from_template(project_id, template)
+ service = template.dup
- if instance_level_service.supports_data_fields?
- data_fields = instance_level_service.data_fields.dup
+ if template.supports_data_fields?
+ data_fields = template.data_fields.dup
data_fields.service = service
end
- service.instance = false
+ service.template = false
service.project_id = project_id
service.active = false if service.active? && !service.valid?
service
@@ -321,6 +321,10 @@ class Service < ApplicationRecord
nil
end
+ def self.find_by_template
+ find_by(template: true)
+ end
+
# override if needed
def supports_data_fields?
false