Commit fb529556 authored by Amit Patel's avatar Amit Patel Committed by Arturo Herrero

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

parent 280776b4
......@@ -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