summaryrefslogtreecommitdiff
path: root/spec/models/integration_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/integration_spec.rb')
-rw-r--r--spec/models/integration_spec.rb31
1 files changed, 9 insertions, 22 deletions
diff --git a/spec/models/integration_spec.rb b/spec/models/integration_spec.rb
index 77b3778122a..d4ea3e5d08a 100644
--- a/spec/models/integration_spec.rb
+++ b/spec/models/integration_spec.rb
@@ -18,6 +18,7 @@ RSpec.describe Integration do
describe 'validations' do
it { is_expected.to validate_presence_of(:type) }
+ it { is_expected.to validate_exclusion_of(:type).in_array(described_class::BASE_CLASSES) }
where(:project_id, :group_id, :template, :instance, :valid) do
1 | nil | false | false | true
@@ -159,7 +160,7 @@ RSpec.describe Integration do
context 'when instance-level service' do
Integration.available_services_types.each do |service_type|
let(:service) do
- service_type.constantize.new(instance: true)
+ described_class.send(:integration_type_to_model, service_type).new(instance: true)
end
it { is_expected.to be_falsey }
@@ -169,7 +170,7 @@ RSpec.describe Integration do
context 'when group-level service' do
Integration.available_services_types.each do |service_type|
let(:service) do
- service_type.constantize.new(group_id: group.id)
+ described_class.send(:integration_type_to_model, service_type).new(group_id: group.id)
end
it { is_expected.to be_falsey }
@@ -446,7 +447,7 @@ RSpec.describe Integration do
describe "for pushover service" do
let!(:service_template) do
- PushoverService.create!(
+ Integrations::Pushover.create!(
template: true,
properties: {
device: 'MyDevice',
@@ -667,16 +668,16 @@ RSpec.describe Integration do
end
end
- describe '.service_name_to_model' do
+ describe '.integration_name_to_model' do
it 'returns the model for the given service name', :aggregate_failures do
- expect(described_class.service_name_to_model('asana')).to eq(Integrations::Asana)
+ expect(described_class.integration_name_to_model('asana')).to eq(Integrations::Asana)
# TODO We can remove this test when all models have been namespaced:
# https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60968#note_570994955
- expect(described_class.service_name_to_model('youtrack')).to eq(YoutrackService)
+ expect(described_class.integration_name_to_model('prometheus')).to eq(PrometheusService)
end
it 'raises an error if service name is invalid' do
- expect { described_class.service_name_to_model('foo') }.to raise_exception(NameError, /uninitialized constant FooService/)
+ expect { described_class.integration_name_to_model('foo') }.to raise_exception(NameError, /uninitialized constant FooService/)
end
end
@@ -802,7 +803,7 @@ RSpec.describe Integration do
describe 'initialize service with no properties' do
let(:service) do
- BugzillaService.create!(
+ Integrations::Bugzilla.create!(
project: project,
project_url: 'http://gitlab.example.com'
)
@@ -896,20 +897,6 @@ RSpec.describe Integration do
end
end
- describe '#external_wiki?' do
- where(:type, :active, :result) do
- 'ExternalWikiService' | true | true
- 'ExternalWikiService' | false | false
- 'SlackService' | true | false
- end
-
- with_them do
- it 'returns the right result' do
- expect(build(:service, type: type, active: active).external_wiki?).to eq(result)
- end
- end
- end
-
describe '.available_services_names' do
it 'calls the right methods' do
expect(described_class).to receive(:services_names).and_call_original