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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-05-23 21:08:14 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-05-23 21:08:14 +0300
commit5e555ebcf6ee2ce13e9956ae599fd811a79b4dbd (patch)
tree6dd67e2f8f49b54e0fb1f266d1720f461393df59 /spec
parent3e53902ee13fc4e0bf3162c0c392dcfe1a0ede4b (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/projects/issues_controller_spec.rb9
-rw-r--r--spec/fixtures/api/schemas/entities/issue.json1
-rw-r--r--spec/fixtures/api/schemas/entities/issue_board.json1
-rw-r--r--spec/frontend/issues/list/components/issues_list_app_spec.js4
-rw-r--r--spec/frontend/issues/show/utils_spec.js116
-rw-r--r--spec/frontend/sidebar/components/assignees/assignee_avatar_link_spec.js24
-rw-r--r--spec/frontend/vue_shared/components/source_viewer/plugins/index_spec.js14
-rw-r--r--spec/frontend/vue_shared/components/source_viewer/plugins/wrap_comments_spec.js20
-rw-r--r--spec/frontend/vue_shared/components/source_viewer/source_viewer_spec.js6
-rw-r--r--spec/lib/gitlab/database/migrations/background_migration_helpers_spec.rb2
-rw-r--r--spec/lib/gitlab/database/migrations/batched_background_migration_helpers_spec.rb74
-rw-r--r--spec/lib/gitlab/database/migrations/reestablished_connection_stack_spec.rb2
-rw-r--r--spec/lib/gitlab/grape_logging/loggers/queue_duration_logger_spec.rb12
-rw-r--r--spec/serializers/issue_board_entity_spec.rb6
-rw-r--r--spec/serializers/issue_entity_spec.rb6
-rw-r--r--spec/services/merge_requests/create_pipeline_service_spec.rb13
-rw-r--r--spec/services/merge_requests/refresh_service_spec.rb15
-rw-r--r--spec/support/shared_examples/lib/gitlab/database/reestablished_connection_stack_shared_examples.rb2
-rw-r--r--spec/workers/merge_requests/create_pipeline_worker_spec.rb37
-rw-r--r--spec/workers/update_merge_requests_worker_spec.rb49
20 files changed, 354 insertions, 59 deletions
diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb
index 8a03c1e709b..a85a4b9b3e6 100644
--- a/spec/controllers/projects/issues_controller_spec.rb
+++ b/spec/controllers/projects/issues_controller_spec.rb
@@ -145,13 +145,18 @@ RSpec.describe Projects::IssuesController do
project.add_developer(user)
end
- it "returns issue_email_participants" do
+ it "returns issue attributes" do
participants = create_list(:issue_email_participant, 2, issue: issue)
get :show, params: { namespace_id: project.namespace, project_id: project, id: issue.iid }, format: :json
expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['issue_email_participants']).to contain_exactly({ "email" => participants[0].email }, { "email" => participants[1].email })
+ expect(json_response).to include(
+ 'issue_email_participants' => contain_exactly(
+ { "email" => participants[0].email }, { "email" => participants[1].email }
+ ),
+ 'type' => 'ISSUE'
+ )
end
end
diff --git a/spec/fixtures/api/schemas/entities/issue.json b/spec/fixtures/api/schemas/entities/issue.json
index 31743b58d98..b4a076780d9 100644
--- a/spec/fixtures/api/schemas/entities/issue.json
+++ b/spec/fixtures/api/schemas/entities/issue.json
@@ -3,6 +3,7 @@
"properties" : {
"id": { "type": "integer" },
"iid": { "type": "integer" },
+ "type": { "type": "string" },
"author_id": { "type": "integer" },
"description": { "type": ["string", "null"] },
"lock_version": { "type": ["integer", "null"] },
diff --git a/spec/fixtures/api/schemas/entities/issue_board.json b/spec/fixtures/api/schemas/entities/issue_board.json
index 58d3832440c..aa29ca08163 100644
--- a/spec/fixtures/api/schemas/entities/issue_board.json
+++ b/spec/fixtures/api/schemas/entities/issue_board.json
@@ -3,6 +3,7 @@
"properties" : {
"id": { "type": "integer" },
"iid": { "type": "integer" },
+ "type": { "type": "string" },
"title": { "type": "string" },
"confidential": { "type": "boolean" },
"closed": { "type": "boolean" },
diff --git a/spec/frontend/issues/list/components/issues_list_app_spec.js b/spec/frontend/issues/list/components/issues_list_app_spec.js
index 7de653e3069..4780851e9c1 100644
--- a/spec/frontend/issues/list/components/issues_list_app_spec.js
+++ b/spec/frontend/issues/list/components/issues_list_app_spec.js
@@ -8,8 +8,6 @@ import VueApollo from 'vue-apollo';
import VueRouter from 'vue-router';
import getIssuesQuery from 'ee_else_ce/issues/list/queries/get_issues.query.graphql';
import getIssuesCountsQuery from 'ee_else_ce/issues/list/queries/get_issues_counts.query.graphql';
-import getIssuesWithoutCrmQuery from 'ee_else_ce/issues/list/queries/get_issues_without_crm.query.graphql';
-import getIssuesCountsWithoutCrmQuery from 'ee_else_ce/issues/list/queries/get_issues_counts_without_crm.query.graphql';
import createMockApollo from 'helpers/mock_apollo_helper';
import setWindowLocation from 'helpers/set_window_location_helper';
import { TEST_HOST } from 'helpers/test_constants';
@@ -121,8 +119,6 @@ describe('CE IssuesListApp component', () => {
const requestHandlers = [
[getIssuesQuery, issuesQueryResponse],
[getIssuesCountsQuery, issuesCountsQueryResponse],
- [getIssuesWithoutCrmQuery, issuesQueryResponse],
- [getIssuesCountsWithoutCrmQuery, issuesCountsQueryResponse],
[setSortPreferenceMutation, sortPreferenceMutationResponse],
];
diff --git a/spec/frontend/issues/show/utils_spec.js b/spec/frontend/issues/show/utils_spec.js
index e5f14cfc01a..603fb5cc2a6 100644
--- a/spec/frontend/issues/show/utils_spec.js
+++ b/spec/frontend/issues/show/utils_spec.js
@@ -2,7 +2,7 @@ import { convertDescriptionWithNewSort } from '~/issues/show/utils';
describe('app/assets/javascripts/issues/show/utils.js', () => {
describe('convertDescriptionWithNewSort', () => {
- it('converts markdown description with new list sort order', () => {
+ it('converts markdown description with nested lists with new list sort order', () => {
const description = `I am text
- Item 1
@@ -12,17 +12,17 @@ describe('app/assets/javascripts/issues/show/utils.js', () => {
- Item 5`;
// Drag Item 2 + children to Item 1's position
- const html = `<ul data-sourcepos="3:1-8:0">
- <li data-sourcepos="4:1-4:8">
+ const html = `<ul data-sourcepos="3:1-7:8">
+ <li data-sourcepos="4:1-6:10">
Item 2
- <ul data-sourcepos="5:1-6:10">
- <li data-sourcepos="5:1-5:10">Item 3</li>
- <li data-sourcepos="6:1-6:10">Item 4</li>
+ <ul data-sourcepos="5:3-6:10">
+ <li data-sourcepos="5:3-5:10">Item 3</li>
+ <li data-sourcepos="6:3-6:10">Item 4</li>
</ul>
</li>
<li data-sourcepos="3:1-3:8">Item 1</li>
- <li data-sourcepos="7:1-8:0">Item 5</li>
- <ul>`;
+ <li data-sourcepos="7:1-7:8">Item 5</li>
+ </ul>`;
const list = document.createElement('div');
list.innerHTML = html;
@@ -36,5 +36,105 @@ describe('app/assets/javascripts/issues/show/utils.js', () => {
expect(convertDescriptionWithNewSort(description, list.firstChild)).toBe(expected);
});
+
+ it('converts markdown description with multi-line list items with new list sort order', () => {
+ const description = `Labore ea omnis et officia excepturi.
+
+1. Item 1
+
+ Item 1 part 2
+
+1. Item 2
+ - Item 2.1
+ - Item 2.1.1
+ - Item 2.1.2
+ - Item 2.2
+ - Item 2.3
+1. Item 3
+1. Item 4
+
+ \`\`\`
+ const variable = 'string';
+ \`\`\`
+
+ ![iii](img.jpg)
+
+ last paragraph
+
+1. Item 5
+1. Item 6`;
+
+ // Drag Item 2 + children to Item 5's position
+ const html = `<ol data-sourcepos="3:1-25:7">
+ <li data-sourcepos="3:1-6:0">
+ <p data-sourcepos="3:4-3:7">Item 1</p>
+ <p data-sourcepos="5:4-5:8">Item 1 part 2</p>
+ </li>
+ <li data-sourcepos="13:1-13:7">
+ <p data-sourcepos="13:4-13:7">Item 3</p>
+ </li>
+ <li data-sourcepos="14:1-23:0">
+ <p data-sourcepos="14:4-14:7">Item 4</p>
+ <div>
+ <pre data-sourcepos="16:4-18:6">
+ <code><span lang="plaintext">const variabl = 'string';</span></code>
+ </pre>
+ </div>
+ <p data-sourcepos="20:4-20:32">
+ <a href="href"><img src="img.jpg" alt="description" /></a>
+ </p>
+ <p data-sourcepos="22:4-22:17">last paragraph</p>
+ </li>
+ <li data-sourcepos="24:1-24:7">
+ <p data-sourcepos="24:4-24:7">Item 5</p>
+ </li>
+ <li data-sourcepos="7:1-12:10">
+ <p data-sourcepos="7:4-7:7">Item 2</p>
+ <ul data-sourcepos="8:4-12:10">
+ <li data-sourcepos="8:4-10:15">Item 2.1
+ <ul data-sourcepos="9:6-10:15">
+ <li data-sourcepos="9:6-9:12">Item 2.1.1</li>
+ <li data-sourcepos="10:6-10:15">Item 2.1.2</li>
+ </ul>
+ </li>
+ <li data-sourcepos="11:4-11:10">Item 2.2</li>
+ <li data-sourcepos="12:4-12:10">Item 2.3</li>
+ </ul>
+ </li>
+ <li data-sourcepos="25:1-25:7">
+ <p data-sourcepos="25:4-25:7">Item 6</p>
+ </li>
+ </ol>`;
+ const list = document.createElement('div');
+ list.innerHTML = html;
+
+ const expected = `Labore ea omnis et officia excepturi.
+
+1. Item 1
+
+ Item 1 part 2
+
+1. Item 3
+1. Item 4
+
+ \`\`\`
+ const variable = 'string';
+ \`\`\`
+
+ ![iii](img.jpg)
+
+ last paragraph
+
+1. Item 5
+1. Item 2
+ - Item 2.1
+ - Item 2.1.1
+ - Item 2.1.2
+ - Item 2.2
+ - Item 2.3
+1. Item 6`;
+
+ expect(convertDescriptionWithNewSort(description, list.firstChild)).toBe(expected);
+ });
});
});
diff --git a/spec/frontend/sidebar/components/assignees/assignee_avatar_link_spec.js b/spec/frontend/sidebar/components/assignees/assignee_avatar_link_spec.js
index 69f6a6e6e04..a286eeef14f 100644
--- a/spec/frontend/sidebar/components/assignees/assignee_avatar_link_spec.js
+++ b/spec/frontend/sidebar/components/assignees/assignee_avatar_link_spec.js
@@ -1,5 +1,8 @@
import { shallowMount } from '@vue/test-utils';
+import { GlLink } from '@gitlab/ui';
import { TEST_HOST } from 'helpers/test_constants';
+import { TYPE_USER } from '~/graphql_shared/constants';
+import { convertToGraphQLId } from '~/graphql_shared/utils';
import AssigneeAvatar from '~/sidebar/components/assignees/assignee_avatar.vue';
import AssigneeAvatarLink from '~/sidebar/components/assignees/assignee_avatar_link.vue';
import userDataMock from '../../user_data_mock';
@@ -32,6 +35,7 @@ describe('AssigneeAvatarLink component', () => {
});
const findTooltipText = () => wrapper.attributes('title');
+ const findUserLink = () => wrapper.findComponent(GlLink);
it('has the root url present in the assigneeUrl method', () => {
createComponent();
@@ -112,4 +116,24 @@ describe('AssigneeAvatarLink component', () => {
});
},
);
+
+ it('passes the correct user id for REST API', () => {
+ createComponent({
+ tooltipHasName: true,
+ user: userDataMock(),
+ });
+
+ expect(findUserLink().attributes('data-user-id')).toBe(String(userDataMock().id));
+ });
+
+ it('passes the correct user id for GraphQL API', () => {
+ const userId = userDataMock().id;
+
+ createComponent({
+ tooltipHasName: true,
+ user: { ...userDataMock(), id: convertToGraphQLId(TYPE_USER, userId) },
+ });
+
+ expect(findUserLink().attributes('data-user-id')).toBe(String(userId));
+ });
});
diff --git a/spec/frontend/vue_shared/components/source_viewer/plugins/index_spec.js b/spec/frontend/vue_shared/components/source_viewer/plugins/index_spec.js
new file mode 100644
index 00000000000..83fdc5d669d
--- /dev/null
+++ b/spec/frontend/vue_shared/components/source_viewer/plugins/index_spec.js
@@ -0,0 +1,14 @@
+import { registerPlugins } from '~/vue_shared/components/source_viewer/plugins/index';
+import { HLJS_ON_AFTER_HIGHLIGHT } from '~/vue_shared/components/source_viewer/constants';
+import wrapComments from '~/vue_shared/components/source_viewer/plugins/wrap_comments';
+
+jest.mock('~/vue_shared/components/source_viewer/plugins/wrap_comments');
+const hljsMock = { addPlugin: jest.fn() };
+
+describe('Highlight.js plugin registration', () => {
+ beforeEach(() => registerPlugins(hljsMock));
+
+ it('registers our plugins', () => {
+ expect(hljsMock.addPlugin).toHaveBeenCalledWith({ [HLJS_ON_AFTER_HIGHLIGHT]: wrapComments });
+ });
+});
diff --git a/spec/frontend/vue_shared/components/source_viewer/plugins/wrap_comments_spec.js b/spec/frontend/vue_shared/components/source_viewer/plugins/wrap_comments_spec.js
new file mode 100644
index 00000000000..5c0cee7781e
--- /dev/null
+++ b/spec/frontend/vue_shared/components/source_viewer/plugins/wrap_comments_spec.js
@@ -0,0 +1,20 @@
+import { HLJS_COMMENT_SELECTOR } from '~/vue_shared/components/source_viewer/constants';
+import wrapComments from '~/vue_shared/components/source_viewer/plugins/wrap_comments';
+
+describe('Highlight.js plugin for wrapping comments', () => {
+ it('mutates the input value by wrapping each line in a span tag', () => {
+ const inputValue = `<span class="${HLJS_COMMENT_SELECTOR}">/* Line 1 \n* Line 2 \n*/</span>`;
+ const outputValue = `<span class="${HLJS_COMMENT_SELECTOR}">/* Line 1 \n<span class="${HLJS_COMMENT_SELECTOR}">* Line 2 </span>\n<span class="${HLJS_COMMENT_SELECTOR}">*/</span>`;
+ const hljsResultMock = { value: inputValue };
+
+ wrapComments(hljsResultMock);
+ expect(hljsResultMock.value).toBe(outputValue);
+ });
+
+ it('does not mutate the input value if the hljs comment selector is not present', () => {
+ const inputValue = '<span class="hljs-keyword">const</span>';
+ const hljsResultMock = { value: inputValue };
+
+ expect(hljsResultMock.value).toBe(inputValue);
+ });
+});
diff --git a/spec/frontend/vue_shared/components/source_viewer/source_viewer_spec.js b/spec/frontend/vue_shared/components/source_viewer/source_viewer_spec.js
index 6a9ea75127d..bb0945a1f3e 100644
--- a/spec/frontend/vue_shared/components/source_viewer/source_viewer_spec.js
+++ b/spec/frontend/vue_shared/components/source_viewer/source_viewer_spec.js
@@ -3,6 +3,7 @@ import Vue from 'vue';
import VueRouter from 'vue-router';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import SourceViewer from '~/vue_shared/components/source_viewer/source_viewer.vue';
+import { registerPlugins } from '~/vue_shared/components/source_viewer/plugins/index';
import Chunk from '~/vue_shared/components/source_viewer/components/chunk.vue';
import { ROUGE_TO_HLJS_LANGUAGE_MAP } from '~/vue_shared/components/source_viewer/constants';
import waitForPromises from 'helpers/wait_for_promises';
@@ -11,6 +12,7 @@ import eventHub from '~/notes/event_hub';
jest.mock('~/blob/line_highlighter');
jest.mock('highlight.js/lib/core');
+jest.mock('~/vue_shared/components/source_viewer/plugins/index');
Vue.use(VueRouter);
const router = new VueRouter();
@@ -59,6 +61,10 @@ describe('Source Viewer component', () => {
describe('highlight.js', () => {
beforeEach(() => createComponent({ language: mappedLanguage }));
+ it('registers our plugins for Highlight.js', () => {
+ expect(registerPlugins).toHaveBeenCalledWith(hljs);
+ });
+
it('registers the language definition', async () => {
const languageDefinition = await import(`highlight.js/lib/languages/${mappedLanguage}`);
diff --git a/spec/lib/gitlab/database/migrations/background_migration_helpers_spec.rb b/spec/lib/gitlab/database/migrations/background_migration_helpers_spec.rb
index b0caa21e01a..c423340a572 100644
--- a/spec/lib/gitlab/database/migrations/background_migration_helpers_spec.rb
+++ b/spec/lib/gitlab/database/migrations/background_migration_helpers_spec.rb
@@ -444,7 +444,7 @@ RSpec.describe Gitlab::Database::Migrations::BackgroundMigrationHelpers do
it 'does restore connection hierarchy' do
expect_next_instances_of(job_class, 1..) do |job|
expect(job).to receive(:perform) do
- validate_connections!
+ validate_connections_stack!
end
end
diff --git a/spec/lib/gitlab/database/migrations/batched_background_migration_helpers_spec.rb b/spec/lib/gitlab/database/migrations/batched_background_migration_helpers_spec.rb
index daddc510963..e1ddc83a3a4 100644
--- a/spec/lib/gitlab/database/migrations/batched_background_migration_helpers_spec.rb
+++ b/spec/lib/gitlab/database/migrations/batched_background_migration_helpers_spec.rb
@@ -3,8 +3,14 @@
require 'spec_helper'
RSpec.describe Gitlab::Database::Migrations::BatchedBackgroundMigrationHelpers do
+ let(:migration_class) do
+ Class.new(ActiveRecord::Migration[6.1])
+ .include(described_class)
+ .include(Gitlab::Database::Migrations::ReestablishedConnectionStack)
+ end
+
let(:migration) do
- ActiveRecord::Migration.new.extend(described_class)
+ migration_class.new
end
describe '#queue_batched_background_migration' do
@@ -221,24 +227,64 @@ RSpec.describe Gitlab::Database::Migrations::BatchedBackgroundMigrationHelpers d
end
end
- context 'when uses a CI connection', :reestablished_active_record_base do
+ context 'when within transaction' do
before do
- skip_if_multiple_databases_not_setup
+ allow(migration).to receive(:transaction_open?).and_return(true)
+ end
- ActiveRecord::Base.establish_connection(:ci) # rubocop:disable Database/EstablishConnection
+ it 'does raise an exception' do
+ expect { migration.finalize_batched_background_migration(job_class_name: 'MyJobClass', table_name: :projects, column_name: :id, job_arguments: []) }
+ .to raise_error /`finalize_batched_background_migration` cannot be run inside a transaction./
end
+ end
- it 'raises an exception' do
- ci_migration = create(:batched_background_migration, :active)
+ context 'when running migration in reconfigured ActiveRecord::Base context' do
+ it_behaves_like 'reconfigures connection stack', 'ci' do
+ before do
+ create(:batched_background_migration,
+ job_class_name: 'Ci::MyClass',
+ table_name: :ci_builds,
+ column_name: :id,
+ job_arguments: [],
+ gitlab_schema: :gitlab_ci)
+ end
- expect do
- migration.finalize_batched_background_migration(
- job_class_name: ci_migration.job_class_name,
- table_name: ci_migration.table_name,
- column_name: ci_migration.column_name,
- job_arguments: ci_migration.job_arguments
- )
- end.to raise_error /is currently not supported when running in decomposed/
+ context 'when restrict_gitlab_migration is set to gitlab_ci' do
+ it 'finalizes the migration' do
+ migration_class.include(Gitlab::Database::MigrationHelpers::RestrictGitlabSchema)
+ migration_class.restrict_gitlab_migration gitlab_schema: :gitlab_ci
+
+ allow_next_instance_of(Gitlab::Database::BackgroundMigration::BatchedMigrationRunner) do |runner|
+ expect(runner).to receive(:finalize).with('Ci::MyClass', :ci_builds, :id, []) do
+ validate_connections_stack!
+ end
+ end
+
+ migration.finalize_batched_background_migration(
+ job_class_name: 'Ci::MyClass', table_name: :ci_builds, column_name: :id, job_arguments: [])
+ end
+ end
+
+ context 'when restrict_gitlab_migration is set to gitlab_main' do
+ it 'does not find any migrations' do
+ migration_class.include(Gitlab::Database::MigrationHelpers::RestrictGitlabSchema)
+ migration_class.restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ expect do
+ migration.finalize_batched_background_migration(
+ job_class_name: 'Ci::MyClass', table_name: :ci_builds, column_name: :id, job_arguments: [])
+ end.to raise_error /Could not find batched background migration/
+ end
+ end
+
+ context 'when no restrict is set' do
+ it 'does not find any migrations' do
+ expect do
+ migration.finalize_batched_background_migration(
+ job_class_name: 'Ci::MyClass', table_name: :ci_builds, column_name: :id, job_arguments: [])
+ end.to raise_error /Could not find batched background migration/
+ end
+ end
end
end
diff --git a/spec/lib/gitlab/database/migrations/reestablished_connection_stack_spec.rb b/spec/lib/gitlab/database/migrations/reestablished_connection_stack_spec.rb
index cfb308c63e4..d197f39be40 100644
--- a/spec/lib/gitlab/database/migrations/reestablished_connection_stack_spec.rb
+++ b/spec/lib/gitlab/database/migrations/reestablished_connection_stack_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe Gitlab::Database::Migrations::ReestablishedConnectionStack do
it_behaves_like "reconfigures connection stack", db_config_name do
it 'does restore connection hierarchy' do
model.with_restored_connection_stack do
- validate_connections!
+ validate_connections_stack!
end
end
diff --git a/spec/lib/gitlab/grape_logging/loggers/queue_duration_logger_spec.rb b/spec/lib/gitlab/grape_logging/loggers/queue_duration_logger_spec.rb
index 4cd9f9dfad0..1924cd687e4 100644
--- a/spec/lib/gitlab/grape_logging/loggers/queue_duration_logger_spec.rb
+++ b/spec/lib/gitlab/grape_logging/loggers/queue_duration_logger_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe Gitlab::GrapeLogging::Loggers::QueueDurationLogger do
describe ".parameters" do
let(:start_time) { Time.new(2018, 01, 01) }
- describe 'when no proxy time is available' do
+ describe 'when no proxy duration is available' do
let(:mock_request) { double('env', env: {}) }
it 'returns an empty hash' do
@@ -16,20 +16,18 @@ RSpec.describe Gitlab::GrapeLogging::Loggers::QueueDurationLogger do
end
end
- describe 'when a proxy time is available' do
+ describe 'when a proxy duration is available' do
let(:mock_request) do
double('env',
env: {
- 'HTTP_GITLAB_WORKHORSE_PROXY_START' => (start_time - 1.hour).to_i * (10**9)
+ 'GITLAB_RAILS_QUEUE_DURATION' => 2.seconds
}
)
end
- it 'returns the correct duration in seconds' do
+ it 'adds the duration to log parameters' do
travel_to(start_time) do
- subject.before
-
- expect(subject.parameters(mock_request, nil)).to eq( { 'queue_duration_s': 1.hour.to_f })
+ expect(subject.parameters(mock_request, nil)).to eq( { 'queue_duration_s': 2.seconds.to_f })
end
end
end
diff --git a/spec/serializers/issue_board_entity_spec.rb b/spec/serializers/issue_board_entity_spec.rb
index b8e2bfeaa3d..7a6a496912f 100644
--- a/spec/serializers/issue_board_entity_spec.rb
+++ b/spec/serializers/issue_board_entity_spec.rb
@@ -43,6 +43,12 @@ RSpec.describe IssueBoardEntity do
expect(subject).to include(labels: array_including(hash_including(:id, :title, :color, :description, :text_color, :priority)))
end
+ describe 'type' do
+ it 'has an issue type' do
+ expect(subject[:type]).to eq('ISSUE')
+ end
+ end
+
describe 'real_path' do
it 'has an issue path' do
expect(subject[:real_path]).to eq(project_issue_path(project, resource.iid))
diff --git a/spec/serializers/issue_entity_spec.rb b/spec/serializers/issue_entity_spec.rb
index 6ccb3dbc657..9525ed02314 100644
--- a/spec/serializers/issue_entity_spec.rb
+++ b/spec/serializers/issue_entity_spec.rb
@@ -24,6 +24,12 @@ RSpec.describe IssueEntity do
end
end
+ describe 'type' do
+ it 'has an issue type' do
+ expect(subject[:type]).to eq('ISSUE')
+ end
+ end
+
it 'has Issuable attributes' do
expect(subject).to include(:id, :iid, :author_id, :description, :lock_version, :milestone_id,
:title, :updated_by_id, :created_at, :updated_at, :milestone, :labels)
diff --git a/spec/services/merge_requests/create_pipeline_service_spec.rb b/spec/services/merge_requests/create_pipeline_service_spec.rb
index d84ce8d15b4..08ad05b54da 100644
--- a/spec/services/merge_requests/create_pipeline_service_spec.rb
+++ b/spec/services/merge_requests/create_pipeline_service_spec.rb
@@ -50,6 +50,19 @@ RSpec.describe MergeRequests::CreatePipelineService do
expect(response.payload.source).to eq('merge_request_event')
end
+ context 'when push options contain ci.skip' do
+ let(:params) { { push_options: { ci: { skip: true } } } }
+
+ it 'creates a skipped pipeline' do
+ expect { response }.to change { Ci::Pipeline.count }.by(1)
+
+ expect(response).to be_success
+ expect(response.payload).to be_persisted
+ expect(response.payload.builds).to be_empty
+ expect(response.payload).to be_skipped
+ end
+ end
+
context 'with fork merge request' do
let_it_be(:forked_project) { fork_project(project, nil, repository: true, target_project: create(:project, :private, :repository)) }
diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb
index 6e6b4a91e0d..7560f0d5e24 100644
--- a/spec/services/merge_requests/refresh_service_spec.rb
+++ b/spec/services/merge_requests/refresh_service_spec.rb
@@ -228,6 +228,21 @@ RSpec.describe MergeRequests::RefreshService do
expect(@another_merge_request.has_commits?).to be_falsy
end
+ context 'when "push_options: nil" is passed' do
+ let(:service_instance) { service.new(project: project, current_user: @user, params: { push_options: nil }) }
+
+ subject { service_instance.execute(@oldrev, @newrev, ref) }
+
+ it 'creates a detached merge request pipeline with commits' do
+ expect { subject }
+ .to change { @merge_request.pipelines_for_merge_request.count }.by(1)
+ .and change { @another_merge_request.pipelines_for_merge_request.count }.by(0)
+
+ expect(@merge_request.has_commits?).to be_truthy
+ expect(@another_merge_request.has_commits?).to be_falsy
+ end
+ end
+
it 'does not create detached merge request pipeline for forked project' do
expect { subject }
.not_to change { @fork_merge_request.pipelines_for_merge_request.count }
diff --git a/spec/support/shared_examples/lib/gitlab/database/reestablished_connection_stack_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/database/reestablished_connection_stack_shared_examples.rb
index 67d739b79ab..d14216ec5ff 100644
--- a/spec/support/shared_examples/lib/gitlab/database/reestablished_connection_stack_shared_examples.rb
+++ b/spec/support/shared_examples/lib/gitlab/database/reestablished_connection_stack_shared_examples.rb
@@ -22,7 +22,7 @@ RSpec.shared_context 'reconfigures connection stack' do |db_config_name|
end
end
- def validate_connections!
+ def validate_connections_stack!
model_connections = Gitlab::Database.database_base_models.to_h do |db_config_name, model_class|
[model_class, Gitlab::Database.db_config_name(model_class.connection)]
end
diff --git a/spec/workers/merge_requests/create_pipeline_worker_spec.rb b/spec/workers/merge_requests/create_pipeline_worker_spec.rb
index 06d44c45706..441d7652219 100644
--- a/spec/workers/merge_requests/create_pipeline_worker_spec.rb
+++ b/spec/workers/merge_requests/create_pipeline_worker_spec.rb
@@ -3,24 +3,50 @@
require 'spec_helper'
RSpec.describe MergeRequests::CreatePipelineWorker do
- subject(:worker) { described_class.new }
-
describe '#perform' do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:merge_request) { create(:merge_request) }
+ let(:worker) { described_class.new }
+
+ subject { worker.perform(project.id, user.id, merge_request.id) }
context 'when the objects exist' do
it 'calls the merge request create pipeline service and calls update head pipeline' do
aggregate_failures do
- expect_next_instance_of(MergeRequests::CreatePipelineService, project: project, current_user: user) do |service|
+ expect_next_instance_of(MergeRequests::CreatePipelineService,
+ project: project,
+ current_user: user,
+ params: { push_options: nil }) do |service|
expect(service).to receive(:execute).with(merge_request)
end
expect(MergeRequest).to receive(:find_by_id).with(merge_request.id).and_return(merge_request)
expect(merge_request).to receive(:update_head_pipeline)
- subject.perform(project.id, user.id, merge_request.id)
+ subject
+ end
+ end
+
+ context 'when push options are passed as Hash to the worker' do
+ let(:extra_params) { { 'push_options' => { 'ci' => { 'skip' => true } } } }
+
+ subject { worker.perform(project.id, user.id, merge_request.id, extra_params) }
+
+ it 'calls the merge request create pipeline service and calls update head pipeline' do
+ aggregate_failures do
+ expect_next_instance_of(MergeRequests::CreatePipelineService,
+ project: project,
+ current_user: user,
+ params: { push_options: { ci: { skip: true } } }) do |service|
+ expect(service).to receive(:execute).with(merge_request)
+ end
+
+ expect(MergeRequest).to receive(:find_by_id).with(merge_request.id).and_return(merge_request)
+ expect(merge_request).to receive(:update_head_pipeline)
+
+ subject
+ end
end
end
end
@@ -29,8 +55,7 @@ RSpec.describe MergeRequests::CreatePipelineWorker do
it 'does not call the create pipeline service' do
expect(MergeRequests::CreatePipelineService).not_to receive(:new)
- expect { subject.perform(project.id, user.id, merge_request.id) }
- .not_to raise_exception
+ expect { subject }.not_to raise_exception
end
end
diff --git a/spec/workers/update_merge_requests_worker_spec.rb b/spec/workers/update_merge_requests_worker_spec.rb
index bd0dc2f9ef4..64fcc2bd388 100644
--- a/spec/workers/update_merge_requests_worker_spec.rb
+++ b/spec/workers/update_merge_requests_worker_spec.rb
@@ -3,28 +3,47 @@
require 'spec_helper'
RSpec.describe UpdateMergeRequestsWorker do
- include RepoHelpers
+ let_it_be(:project) { create(:project, :repository) }
+ let_it_be(:user) { create(:user) }
+ let_it_be(:oldrev) { "123456" }
+ let_it_be(:newrev) { "789012" }
+ let_it_be(:ref) { "refs/heads/test" }
- let(:project) { create(:project, :repository) }
- let(:user) { create(:user) }
-
- subject { described_class.new }
+ let(:worker) { described_class.new }
describe '#perform' do
- let(:oldrev) { "123456" }
- let(:newrev) { "789012" }
- let(:ref) { "refs/heads/test" }
-
- def perform
- subject.perform(project.id, user.id, oldrev, newrev, ref)
- end
+ subject { worker.perform(project.id, user.id, oldrev, newrev, ref) }
it 'executes MergeRequests::RefreshService with expected values' do
- expect_next_instance_of(MergeRequests::RefreshService, project: project, current_user: user) do |refresh_service|
- expect(refresh_service).to receive(:execute).with(oldrev, newrev, ref)
+ expect_next_instance_of(MergeRequests::RefreshService,
+ project: project,
+ current_user: user,
+ params: { push_options: nil }) do |service|
+ expect(service)
+ .to receive(:execute)
+ .with(oldrev, newrev, ref)
end
- perform
+ subject
+ end
+
+ context 'when push options are passed as Hash' do
+ let(:extra_params) { { 'push_options' => { 'ci' => { 'skip' => true } } } }
+
+ subject { worker.perform(project.id, user.id, oldrev, newrev, ref, extra_params) }
+
+ it 'executes MergeRequests::RefreshService with expected values' do
+ expect_next_instance_of(MergeRequests::RefreshService,
+ project: project,
+ current_user: user,
+ params: { push_options: { ci: { skip: true } } }) do |service|
+ expect(service)
+ .to receive(:execute)
+ .with(oldrev, newrev, ref)
+ end
+
+ subject
+ end
end
end
end