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
path: root/spec/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-27 15:07:43 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-27 15:07:43 +0300
commit39fa7d1eeb2dba52f0601128f3ac91f57d19866e (patch)
treeda042d34ff762dd1957e51666a34202295a081b9 /spec/lib
parent6ac4a6713ed3196af899011f7e18658e16ebaac0 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/auth/current_user_mode_spec.rb2
-rw-r--r--spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb8
-rw-r--r--spec/lib/gitlab/email/message/repository_push_spec.rb2
-rw-r--r--spec/lib/gitlab/gfm/uploads_rewriter_spec.rb2
-rw-r--r--spec/lib/gitlab/import_export/all_models.yml1
-rw-r--r--spec/lib/gitlab/import_formatter_spec.rb35
-rw-r--r--spec/lib/gitlab/jira_import/issue_serializer_spec.rb89
7 files changed, 132 insertions, 7 deletions
diff --git a/spec/lib/gitlab/auth/current_user_mode_spec.rb b/spec/lib/gitlab/auth/current_user_mode_spec.rb
index 8863f26fbf2..26e44fa7cc8 100644
--- a/spec/lib/gitlab/auth/current_user_mode_spec.rb
+++ b/spec/lib/gitlab/auth/current_user_mode_spec.rb
@@ -196,7 +196,7 @@ describe Gitlab::Auth::CurrentUserMode, :do_not_mock_admin_mode, :request_store
subject.request_admin_mode!
subject.enable_admin_mode!(password: user.password)
- expect(session).to include(expected_session_entry(be_within(1.second).of Time.now))
+ expect(session).to include(expected_session_entry(be_within(1.second).of(Time.now)))
end
end
diff --git a/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb b/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb
index 243c6f06324..7a413a7aeac 100644
--- a/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb
+++ b/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb
@@ -66,7 +66,7 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do
describe '#children' do
subject { |example| path(example).children }
- it { is_expected.to all(be_an_instance_of described_class) }
+ it { is_expected.to all(be_an_instance_of(described_class)) }
it do
is_expected.to contain_exactly entry('path/dir_1/file_1'),
entry('path/dir_1/file_b'),
@@ -78,7 +78,7 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do
subject { |example| path(example).files }
it { is_expected.to all(be_file) }
- it { is_expected.to all(be_an_instance_of described_class) }
+ it { is_expected.to all(be_an_instance_of(described_class)) }
it do
is_expected.to contain_exactly entry('path/dir_1/file_1'),
entry('path/dir_1/file_b')
@@ -90,7 +90,7 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do
subject { |example| path(example).directories }
it { is_expected.to all(be_directory) }
- it { is_expected.to all(be_an_instance_of described_class) }
+ it { is_expected.to all(be_an_instance_of(described_class)) }
it { is_expected.to contain_exactly entry('path/dir_1/subdir/') }
end
@@ -98,7 +98,7 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do
subject { |example| path(example).directories(parent: true) }
it { is_expected.to all(be_directory) }
- it { is_expected.to all(be_an_instance_of described_class) }
+ it { is_expected.to all(be_an_instance_of(described_class)) }
it do
is_expected.to contain_exactly entry('path/dir_1/subdir/'),
entry('path/')
diff --git a/spec/lib/gitlab/email/message/repository_push_spec.rb b/spec/lib/gitlab/email/message/repository_push_spec.rb
index b57764bceef..9e95d31f41c 100644
--- a/spec/lib/gitlab/email/message/repository_push_spec.rb
+++ b/spec/lib/gitlab/email/message/repository_push_spec.rb
@@ -69,7 +69,7 @@ describe Gitlab::Email::Message::RepositoryPush do
describe '#diffs' do
subject { message.diffs }
- it { is_expected.to all(be_an_instance_of Gitlab::Diff::File) }
+ it { is_expected.to all(be_an_instance_of(Gitlab::Diff::File)) }
end
describe '#diffs_count' do
diff --git a/spec/lib/gitlab/gfm/uploads_rewriter_spec.rb b/spec/lib/gitlab/gfm/uploads_rewriter_spec.rb
index ebd7c7af265..0bf46217d60 100644
--- a/spec/lib/gitlab/gfm/uploads_rewriter_spec.rb
+++ b/spec/lib/gitlab/gfm/uploads_rewriter_spec.rb
@@ -74,7 +74,7 @@ describe Gitlab::Gfm::UploadsRewriter do
end
it 'throw an error' do
- expect { rewriter.rewrite(new_project) }.to raise_error(an_instance_of(StandardError).and having_attributes(message: "Invalid path"))
+ expect { rewriter.rewrite(new_project) }.to raise_error(an_instance_of(StandardError).and(having_attributes(message: "Invalid path")))
end
end
diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml
index 0ed5a1e7b49..9abc8a5d88f 100644
--- a/spec/lib/gitlab/import_export/all_models.yml
+++ b/spec/lib/gitlab/import_export/all_models.yml
@@ -252,6 +252,7 @@ services:
- service_hook
- jira_tracker_data
- issue_tracker_data
+- open_project_tracker_data
hooks:
- project
- web_hook_logs
diff --git a/spec/lib/gitlab/import_formatter_spec.rb b/spec/lib/gitlab/import_formatter_spec.rb
new file mode 100644
index 00000000000..e9f63ba5777
--- /dev/null
+++ b/spec/lib/gitlab/import_formatter_spec.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::ImportFormatter do
+ let(:formatter) { Gitlab::ImportFormatter.new }
+
+ describe '#comment' do
+ it 'creates the correct string' do
+ expect(formatter.comment('Name', '2020-02-02', 'some text')).to eq(
+ "\n\n*By Name on 2020-02-02*\n\nsome text"
+ )
+ end
+ end
+
+ describe '#author_line' do
+ it 'returns the correct string with provided author name' do
+ expect(formatter.author_line('Name')).to eq("*Created by: Name*\n\n")
+ end
+
+ it 'returns the correct string with Anonymous name if author not provided' do
+ expect(formatter.author_line(nil)).to eq("*Created by: Anonymous*\n\n")
+ end
+ end
+
+ describe '#assignee_line' do
+ it 'returns the correct string with provided author name' do
+ expect(formatter.assignee_line('Name')).to eq("*Assigned to: Name*\n\n")
+ end
+
+ it 'returns the correct string with Anonymous name if author not provided' do
+ expect(formatter.assignee_line(nil)).to eq("*Assigned to: Anonymous*\n\n")
+ end
+ end
+end
diff --git a/spec/lib/gitlab/jira_import/issue_serializer_spec.rb b/spec/lib/gitlab/jira_import/issue_serializer_spec.rb
new file mode 100644
index 00000000000..03631a3e941
--- /dev/null
+++ b/spec/lib/gitlab/jira_import/issue_serializer_spec.rb
@@ -0,0 +1,89 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::JiraImport::IssueSerializer do
+ describe '#execute' do
+ let_it_be(:project) { create(:project) }
+
+ let(:iid) { 5 }
+ let(:key) { 'PROJECT-5' }
+ let(:summary) { 'some title' }
+ let(:description) { 'basic description' }
+ let(:created_at) { '2020-01-01 20:00:00' }
+ let(:updated_at) { '2020-01-10 20:00:00' }
+ let(:assignee) { double(displayName: 'Solver') }
+ let(:jira_status) { 'new' }
+ let(:jira_issue) do
+ double(
+ id: '1234',
+ key: key,
+ summary: summary,
+ description: description,
+ created: created_at,
+ updated: updated_at,
+ assignee: assignee,
+ reporter: double(displayName: 'Reporter'),
+ status: double(statusCategory: { 'key' => jira_status })
+ )
+ end
+ let(:params) { { iid: iid } }
+
+ let(:expected_description) do
+ <<~MD
+ *Created by: Reporter*
+
+ *Assigned to: Solver*
+
+ basic description
+ MD
+ end
+
+ subject { described_class.new(project, jira_issue, params).execute }
+
+ context 'attributes setting' do
+ it 'sets the basic attributes' do
+ expect(subject).to eq(
+ iid: iid,
+ project_id: project.id,
+ description: expected_description.strip,
+ title: "[#{key}] #{summary}",
+ state_id: 1,
+ updated_at: updated_at,
+ created_at: created_at,
+ author_id: project.creator_id
+ )
+ end
+ end
+
+ context 'with done status' do
+ let(:jira_status) { 'done' }
+
+ it 'maps the status to closed' do
+ expect(subject[:state_id]).to eq(2)
+ end
+ end
+
+ context 'without the assignee' do
+ let(:assignee) { nil }
+
+ it 'does not include assignee in the description' do
+ expected_description = <<~MD
+ *Created by: Reporter*
+
+ basic description
+ MD
+
+ expect(subject[:description]).to eq(expected_description.strip)
+ end
+ end
+
+ context 'without the iid' do
+ let(:params) { {} }
+
+ it 'does not set the iid' do
+ expect(subject[:iid]).to be_nil
+ end
+ end
+ end
+end