Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/integrations')
-rw-r--r--spec/models/integrations/base_third_party_wiki_spec.rb46
-rw-r--r--spec/models/integrations/field_spec.rb16
-rw-r--r--spec/models/integrations/irker_spec.rb9
-rw-r--r--spec/models/integrations/shimo_spec.rb69
4 files changed, 19 insertions, 121 deletions
diff --git a/spec/models/integrations/base_third_party_wiki_spec.rb b/spec/models/integrations/base_third_party_wiki_spec.rb
deleted file mode 100644
index 763f7131b94..00000000000
--- a/spec/models/integrations/base_third_party_wiki_spec.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Integrations::BaseThirdPartyWiki, feature_category: :integrations do
- describe 'default values' do
- it { expect(subject.category).to eq(:third_party_wiki) }
- end
-
- describe 'Validations' do
- let_it_be_with_reload(:project) { create(:project) }
-
- describe 'only one third party wiki per project' do
- subject(:integration) { build(:shimo_integration, project: project, active: true) }
-
- before_all do
- create(:confluence_integration, project: project, active: true)
- end
-
- context 'when integration is changed manually by user' do
- it 'executes the validation' do
- valid = integration.valid?(:manual_change)
-
- expect(valid).to be_falsey
- error_message = 'Another third-party wiki is already in use. '\
- 'Only one third-party wiki integration can be active at a time'
- expect(integration.errors[:base]).to include _(error_message)
- end
- end
-
- context 'when integration is changed internally' do
- it 'does not execute the validation' do
- expect(integration.valid?).to be_truthy
- end
- end
-
- context 'when integration is not on the project level' do
- subject(:integration) { build(:shimo_integration, :instance, active: true) }
-
- it 'executes the validation' do
- expect(integration.valid?(:manual_change)).to be_truthy
- end
- end
- end
- end
-end
diff --git a/spec/models/integrations/field_spec.rb b/spec/models/integrations/field_spec.rb
index 49eaecd1b2e..22ad71135e7 100644
--- a/spec/models/integrations/field_spec.rb
+++ b/spec/models/integrations/field_spec.rb
@@ -186,6 +186,22 @@ RSpec.describe ::Integrations::Field, feature_category: :integrations do
end
end
+ describe '#api_type' do
+ it 'returns String' do
+ expect(field.api_type).to eq(String)
+ end
+
+ context 'when type is checkbox' do
+ before do
+ attrs[:type] = :checkbox
+ end
+
+ it 'returns Boolean' do
+ expect(field.api_type).to eq(::API::Integrations::Boolean)
+ end
+ end
+ end
+
describe '#key?' do
it { is_expected.to be_key(:type) }
it { is_expected.not_to be_key(:foo) }
diff --git a/spec/models/integrations/irker_spec.rb b/spec/models/integrations/irker_spec.rb
index e98b8b54e03..2a733e67a3c 100644
--- a/spec/models/integrations/irker_spec.rb
+++ b/spec/models/integrations/irker_spec.rb
@@ -5,7 +5,7 @@ require 'socket'
require 'timeout'
require 'json'
-RSpec.describe Integrations::Irker do
+RSpec.describe Integrations::Irker, feature_category: :integrations do
describe 'Validations' do
context 'when integration is active' do
before do
@@ -30,10 +30,7 @@ RSpec.describe Integrations::Irker do
let(:irker) { described_class.new }
let(:irker_server) { TCPServer.new('localhost', 0) }
- let(:sample_data) do
- Gitlab::DataBuilder::Push.build_sample(project, user)
- end
-
+ let(:sample_data) { Gitlab::DataBuilder::Push.build_sample(project, user) }
let(:recipients) { '#commits irc://test.net/#test ftp://bad' }
let(:colorize_messages) { '1' }
@@ -58,7 +55,7 @@ RSpec.describe Integrations::Irker do
it 'sends valid JSON messages to an Irker listener', :sidekiq_might_not_need_inline do
expect(Integrations::IrkerWorker).to receive(:perform_async)
- .with(project.id, irker.channels, colorize_messages, sample_data, irker.settings)
+ .with(project.id, irker.channels, colorize_messages, sample_data.deep_stringify_keys, irker.settings)
.and_call_original
irker.execute(sample_data)
diff --git a/spec/models/integrations/shimo_spec.rb b/spec/models/integrations/shimo_spec.rb
deleted file mode 100644
index 95289343d0d..00000000000
--- a/spec/models/integrations/shimo_spec.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe ::Integrations::Shimo, feature_category: :integrations do
- describe '#fields' do
- let(:shimo_integration) { build(:shimo_integration) }
-
- it 'returns custom fields' do
- expect(shimo_integration.fields.pluck(:name)).to eq(%w[external_wiki_url])
- end
- end
-
- describe '#create' do
- let_it_be(:project) { create(:project, :repository) }
- let(:external_wiki_url) { 'https://shimo.example.com/desktop' }
- let(:params) { { active: true, project: project, external_wiki_url: external_wiki_url } }
-
- context 'with valid params' do
- it 'creates the Shimo integration' do
- shimo = described_class.create!(params)
-
- expect(shimo.valid?).to be true
- expect(shimo.render?).to be true
- expect(shimo.external_wiki_url).to eq(external_wiki_url)
- end
- end
-
- context 'with invalid params' do
- it 'cannot create the Shimo integration without external_wiki_url' do
- params['external_wiki_url'] = nil
- expect { described_class.create!(params) }.to raise_error(ActiveRecord::RecordInvalid)
- end
-
- it 'cannot create the Shimo integration with invalid external_wiki_url' do
- params['external_wiki_url'] = 'Fake Invalid URL'
- expect { described_class.create!(params) }.to raise_error(ActiveRecord::RecordInvalid)
- end
- end
- end
-
- describe 'Caching has_shimo on project_settings' do
- let_it_be(:project) { create(:project) }
-
- subject { project.project_setting.has_shimo? }
-
- it 'sets the property to true when integration is active' do
- create(:shimo_integration, project: project, active: true)
-
- is_expected.to be(true)
- end
-
- it 'sets the property to false when integration is not active' do
- create(:shimo_integration, project: project, active: false)
-
- is_expected.to be(false)
- end
-
- it 'creates a project_setting record if one was not already created' do
- expect { create(:shimo_integration) }.to change(ProjectSetting, :count).by(1)
- end
- end
-
- describe '#avatar_url' do
- it 'returns the avatar image path' do
- expect(subject.avatar_url).to eq(ActionController::Base.helpers.image_path('logos/shimo.svg'))
- end
- end
-end