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:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-02-01 00:07:40 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-01 00:07:40 +0300
commit9e83d078577a9c066f21fcef1355f800ad895c9c (patch)
tree8995c5868449584040e58400ae2bcb9f48346fb3 /spec/services
parent22dde36e800253350e5fa1d902f191a7f64bc6e9 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/import_csv/base_service_spec.rb64
-rw-r--r--spec/services/issues/import_csv_service_spec.rb2
-rw-r--r--spec/services/jira_connect_installations/update_service_spec.rb18
3 files changed, 75 insertions, 9 deletions
diff --git a/spec/services/import_csv/base_service_spec.rb b/spec/services/import_csv/base_service_spec.rb
new file mode 100644
index 00000000000..0c0ed40ff4d
--- /dev/null
+++ b/spec/services/import_csv/base_service_spec.rb
@@ -0,0 +1,64 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe ImportCsv::BaseService, feature_category: :importers do
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project) }
+ let_it_be(:csv_io) { double }
+
+ subject { described_class.new(user, project, csv_io) }
+
+ shared_examples 'abstract method' do |method, args|
+ it "raises NotImplemented error when #{method} is called" do
+ if args
+ expect { subject.send(method, args) }.to raise_error(NotImplementedError)
+ else
+ expect { subject.send(method) }.to raise_error(NotImplementedError)
+ end
+ end
+ end
+
+ it_behaves_like 'abstract method', :email_results_to_user
+ it_behaves_like 'abstract method', :attributes_for, "any"
+ it_behaves_like 'abstract method', :validate_headers_presence!, "any"
+ it_behaves_like 'abstract method', :create_object_class
+
+ describe '#detect_col_sep' do
+ context 'when header contains invalid separators' do
+ it 'raises error' do
+ header = 'Name&email'
+
+ expect { subject.send(:detect_col_sep, header) }.to raise_error(CSV::MalformedCSVError)
+ end
+ end
+
+ context 'when header is valid' do
+ shared_examples 'header with valid separators' do
+ let(:header) { "Name#{separator}email" }
+
+ it 'returns separator value' do
+ expect(subject.send(:detect_col_sep, header)).to eq(separator)
+ end
+ end
+
+ context 'with ; as separator' do
+ let(:separator) { ';' }
+
+ it_behaves_like 'header with valid separators'
+ end
+
+ context 'with \t as separator' do
+ let(:separator) { "\t" }
+
+ it_behaves_like 'header with valid separators'
+ end
+
+ context 'with , as separator' do
+ let(:separator) { ',' }
+
+ it_behaves_like 'header with valid separators'
+ end
+ end
+ end
+end
diff --git a/spec/services/issues/import_csv_service_spec.rb b/spec/services/issues/import_csv_service_spec.rb
index 9ad1d7dba9f..90e360f9cf1 100644
--- a/spec/services/issues/import_csv_service_spec.rb
+++ b/spec/services/issues/import_csv_service_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Issues::ImportCsvService do
+RSpec.describe Issues::ImportCsvService, feature_category: :team_planning do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:assignee) { create(:user, username: 'csv_assignee') }
diff --git a/spec/services/jira_connect_installations/update_service_spec.rb b/spec/services/jira_connect_installations/update_service_spec.rb
index ec5bb5d6d6a..15f3b485b20 100644
--- a/spec/services/jira_connect_installations/update_service_spec.rb
+++ b/spec/services/jira_connect_installations/update_service_spec.rb
@@ -45,8 +45,9 @@ RSpec.describe JiraConnectInstallations::UpdateService, feature_category: :integ
let_it_be_with_reload(:installation) { create(:jira_connect_installation, instance_url: 'https://other_gitlab.example.com') }
it 'sends an installed event to the instance', :aggregate_failures do
- expect_next_instance_of(JiraConnectInstallations::ProxyLifecycleEventService, installation, :installed,
-'https://other_gitlab.example.com') do |proxy_lifecycle_events_service|
+ expect_next_instance_of(
+ JiraConnectInstallations::ProxyLifecycleEventService, installation, :installed, 'https://other_gitlab.example.com'
+ ) do |proxy_lifecycle_events_service|
expect(proxy_lifecycle_events_service).to receive(:execute).and_return(ServiceResponse.new(status: :success))
end
@@ -62,19 +63,19 @@ RSpec.describe JiraConnectInstallations::UpdateService, feature_category: :integ
stub_request(:post, 'https://other_gitlab.example.com/-/jira_connect/events/uninstalled')
end
- it 'starts an async worker to send an uninstalled event to the previous instance' do
- expect(JiraConnect::SendUninstalledHookWorker).to receive(:perform_async).with(installation.id, 'https://other_gitlab.example.com')
-
+ it 'sends an installed event to the instance and updates instance_url' do
expect(JiraConnectInstallations::ProxyLifecycleEventService)
.to receive(:execute).with(installation, :installed, 'https://gitlab.example.com')
.and_return(ServiceResponse.new(status: :success))
+ expect(JiraConnect::SendUninstalledHookWorker).not_to receive(:perform_async)
+
execute_service
expect(installation.instance_url).to eq(update_params[:instance_url])
end
- context 'and the new instance_url is empty' do
+ context 'and the new instance_url is nil' do
let(:update_params) { { instance_url: nil } }
it 'starts an async worker to send an uninstalled event to the previous instance' do
@@ -98,8 +99,9 @@ RSpec.describe JiraConnectInstallations::UpdateService, feature_category: :integ
let(:update_params) { { instance_url: 'https://gitlab.example.com' } }
it 'sends an installed event to the instance and updates instance_url' do
- expect_next_instance_of(JiraConnectInstallations::ProxyLifecycleEventService, installation, :installed,
-'https://gitlab.example.com') do |proxy_lifecycle_events_service|
+ expect_next_instance_of(
+ JiraConnectInstallations::ProxyLifecycleEventService, installation, :installed, 'https://gitlab.example.com'
+ ) do |proxy_lifecycle_events_service|
expect(proxy_lifecycle_events_service).to receive(:execute).and_return(ServiceResponse.new(status: :success))
end