Commit 468b221d authored by Arturo Herrero's avatar Arturo Herrero

Merge branch '326079-add-group-level-and-instance-level-helpers-to-service-model' into 'master'

Add group_level? and instance_level? helpers to service.rb model

See merge request gitlab-org/gitlab!59838
parents 440ee437 fb529556
......@@ -416,6 +416,14 @@ class Service < ApplicationRecord
project_id.present?
end
def group_level?
group_id.present?
end
def instance_level?
instance?
end
def parent
project || group
end
......
---
title: Add group_level? and instance_level? helpers to Service model
merge_request: 59838
author: Amit Patel @amit.savani
type: other
......@@ -212,6 +212,26 @@ RSpec.describe Service do
end
end
describe '#group_level?' do
it 'is true when service has a group' do
expect(build(:service, group: group)).to be_group_level
end
it 'is false when service has no group' do
expect(build(:service, group: nil)).not_to be_group_level
end
end
describe '#instance_level?' do
it 'is true when service has instance-level integration' do
expect(build(:service, :instance)).to be_instance_level
end
it 'is false when service does not have instance-level integration' do
expect(build(:service, instance: false)).not_to be_instance_level
end
end
describe '.find_or_initialize_non_project_specific_integration' do
let!(:service1) { create(:jira_service, project_id: nil, group_id: group.id) }
let!(:service2) { create(:jira_service) }
......
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