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>2023-02-16 18:07:53 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-16 18:07:53 +0300
commitc1f98d9590def61ad2fca09cc06a7a9d52cdebc5 (patch)
tree84490eecee06513f152cd466ed7c1d23a71a6ddf /spec
parent12166c0faf75479889bc0ac432b85b9dae91552b (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/config/settings_spec.rb8
-rw-r--r--spec/features/issues/user_edits_issue_spec.rb2
-rw-r--r--spec/finders/ci/pipeline_schedules_finder_spec.rb43
-rw-r--r--spec/frontend/import_entities/import_groups/components/import_table_spec.js1
-rw-r--r--spec/frontend/import_entities/import_projects/components/provider_repo_table_row_spec.js67
-rw-r--r--spec/frontend/import_entities/import_projects/store/mutations_spec.js26
-rw-r--r--spec/frontend/import_entities/import_projects/utils_spec.js2
-rw-r--r--spec/frontend/issues/dashboard/components/issues_dashboard_app_spec.js4
-rw-r--r--spec/frontend/vue_merge_request_widget/components/states/mr_widget_conflicts_spec.js1
-rw-r--r--spec/graphql/resolvers/data_transfer_resolver_spec.rb31
-rw-r--r--spec/lib/gitlab/api_authentication/token_resolver_spec.rb6
-rw-r--r--spec/lib/gitlab/auth/auth_finders_spec.rb6
-rw-r--r--spec/lib/gitlab/external_authorization/config_spec.rb23
-rw-r--r--spec/lib/gitlab/git_access_spec.rb8
-rw-r--r--spec/lib/gitlab/github_import/logger_spec.rb12
-rw-r--r--spec/lib/gitlab/import/logger_spec.rb12
-rw-r--r--spec/lib/gitlab/import_export/import_export_equivalence_spec.rb5
-rw-r--r--spec/lib/gitlab/json_logger_spec.rb8
-rw-r--r--spec/lib/gitlab/redis/multi_store_spec.rb18
-rw-r--r--spec/models/ci/group_variable_spec.rb7
-rw-r--r--spec/models/ci/variable_spec.rb7
-rw-r--r--spec/requests/api/ci/variables_spec.rb129
-rw-r--r--spec/requests/api/draft_notes_spec.rb58
-rw-r--r--spec/requests/api/group_variables_spec.rb105
-rw-r--r--spec/serializers/issue_entity_spec.rb2
-rw-r--r--spec/services/issues/after_create_service_spec.rb2
-rw-r--r--spec/services/issues/close_service_spec.rb22
-rw-r--r--spec/services/issues/duplicate_service_spec.rb2
-rw-r--r--spec/services/issues/referenced_merge_requests_service_spec.rb2
-rw-r--r--spec/services/issues/related_branches_service_spec.rb4
-rw-r--r--spec/services/issues/reopen_service_spec.rb6
-rw-r--r--spec/services/issues/reorder_service_spec.rb2
-rw-r--r--spec/services/issues/update_service_spec.rb24
-rw-r--r--spec/services/issues/zoom_link_service_spec.rb2
-rw-r--r--spec/services/tasks_to_be_done/base_service_spec.rb2
-rw-r--r--spec/services/work_items/update_service_spec.rb6
-rw-r--r--spec/support/helpers/cycle_analytics_helpers.rb2
-rw-r--r--spec/support/import_export/common_util.rb14
-rw-r--r--spec/support/services/issuable_update_service_shared_examples.rb4
-rw-r--r--spec/support/shared_examples/features/work_items_shared_examples.rb2
-rw-r--r--spec/support/shared_examples/requests/api/time_tracking_shared_examples.rb2
-rw-r--r--spec/support/shared_examples/services/issuable_shared_examples.rb3
-rw-r--r--spec/support/shared_examples/services/updating_mentions_shared_examples.rb3
-rw-r--r--spec/workers/incident_management/close_incident_worker_spec.rb2
-rw-r--r--spec/workers/issues/close_worker_spec.rb2
-rw-r--r--spec/workers/merge_requests/close_issue_worker_spec.rb2
46 files changed, 469 insertions, 232 deletions
diff --git a/spec/config/settings_spec.rb b/spec/config/settings_spec.rb
index 1aa1d885be3..0928f2b72ff 100644
--- a/spec/config/settings_spec.rb
+++ b/spec/config/settings_spec.rb
@@ -190,4 +190,12 @@ RSpec.describe Settings, feature_category: :authentication_and_authorization do
expect(described_class.microsoft_graph_mailer.graph_endpoint).to eq('https://graph.microsoft.com')
end
end
+
+ describe '.repositories' do
+ it 'sets up storage settings' do
+ described_class.repositories.storages.each do |_, storage|
+ expect(storage).to be_a Gitlab::GitalyClient::StorageSettings
+ end
+ end
+ end
end
diff --git a/spec/features/issues/user_edits_issue_spec.rb b/spec/features/issues/user_edits_issue_spec.rb
index a8a747e188e..bf2af918f39 100644
--- a/spec/features/issues/user_edits_issue_spec.rb
+++ b/spec/features/issues/user_edits_issue_spec.rb
@@ -26,7 +26,7 @@ RSpec.describe "Issues > User edits issue", :js, feature_category: :team_plannin
visit edit_project_issue_path(project, issue)
end
- it "previews content" do
+ it "previews content", quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/391757' do
form = first(".gfm-form")
page.within(form) do
diff --git a/spec/finders/ci/pipeline_schedules_finder_spec.rb b/spec/finders/ci/pipeline_schedules_finder_spec.rb
index 535c684289e..4699592b6d4 100644
--- a/spec/finders/ci/pipeline_schedules_finder_spec.rb
+++ b/spec/finders/ci/pipeline_schedules_finder_spec.rb
@@ -15,8 +15,39 @@ RSpec.describe Ci::PipelineSchedulesFinder do
let(:params) { { scope: nil } }
it 'selects all pipeline schedules' do
- expect(subject.count).to be(2)
- expect(subject).to include(active_schedule, inactive_schedule)
+ expect(subject).to contain_exactly(active_schedule, inactive_schedule)
+ end
+ end
+
+ context 'when the id is nil' do
+ let(:params) { { ids: nil } }
+
+ it 'selects all pipeline schedules' do
+ expect(subject).to contain_exactly(active_schedule, inactive_schedule)
+ end
+ end
+
+ context 'when the id is a single pipeline schedule' do
+ let(:params) { { ids: active_schedule.id } }
+
+ it 'selects one pipeline schedule' do
+ expect(subject).to contain_exactly(active_schedule)
+ end
+ end
+
+ context 'when multiple ids are provided' do
+ let(:params) { { ids: [active_schedule.id, inactive_schedule.id] } }
+
+ it 'selects multiple pipeline schedules' do
+ expect(subject).to contain_exactly(active_schedule, inactive_schedule)
+ end
+ end
+
+ context 'when multiple ids are provided and a scope is set' do
+ let(:params) { { scope: 'active', ids: [active_schedule.id, inactive_schedule.id] } }
+
+ it 'selects one pipeline schedule' do
+ expect(subject).to contain_exactly(active_schedule)
end
end
@@ -24,9 +55,7 @@ RSpec.describe Ci::PipelineSchedulesFinder do
let(:params) { { scope: 'active' } }
it 'selects only active pipelines' do
- expect(subject.count).to be(1)
- expect(subject).to include(active_schedule)
- expect(subject).not_to include(inactive_schedule)
+ expect(subject).to contain_exactly(active_schedule)
end
end
@@ -34,9 +63,7 @@ RSpec.describe Ci::PipelineSchedulesFinder do
let(:params) { { scope: 'inactive' } }
it 'selects only inactive pipelines' do
- expect(subject.count).to be(1)
- expect(subject).not_to include(active_schedule)
- expect(subject).to include(inactive_schedule)
+ expect(subject).to contain_exactly(inactive_schedule)
end
end
end
diff --git a/spec/frontend/import_entities/import_groups/components/import_table_spec.js b/spec/frontend/import_entities/import_groups/components/import_table_spec.js
index 00b69948bfb..c7bda5a60ec 100644
--- a/spec/frontend/import_entities/import_groups/components/import_table_spec.js
+++ b/spec/frontend/import_entities/import_groups/components/import_table_spec.js
@@ -40,6 +40,7 @@ describe('import table', () => {
generateFakeEntry({ id: 2, status: STATUSES.FINISHED }),
generateFakeEntry({ id: 3, status: STATUSES.NONE }),
];
+
const FAKE_PAGE_INFO = { page: 1, perPage: 20, total: 40, totalPages: 2 };
const FAKE_VERSION_VALIDATION = {
features: {
diff --git a/spec/frontend/import_entities/import_projects/components/provider_repo_table_row_spec.js b/spec/frontend/import_entities/import_projects/components/provider_repo_table_row_spec.js
index d686036781f..e613b9756af 100644
--- a/spec/frontend/import_entities/import_projects/components/provider_repo_table_row_spec.js
+++ b/spec/frontend/import_entities/import_projects/components/provider_repo_table_row_spec.js
@@ -1,4 +1,4 @@
-import { GlBadge, GlButton, GlDropdown } from '@gitlab/ui';
+import { GlBadge, GlButton } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import Vue, { nextTick } from 'vue';
import Vuex from 'vuex';
@@ -31,12 +31,16 @@ describe('ProviderRepoTableRow', () => {
return store;
}
- const findImportButton = () => {
- const buttons = wrapper.findAllComponents(GlButton).filter((node) => node.text() === 'Import');
+ const findButton = (text) => {
+ const buttons = wrapper.findAllComponents(GlButton).filter((node) => node.text() === text);
return buttons.length ? buttons.at(0) : buttons;
};
+ const findImportButton = () => findButton('Import');
+ const findReimportButton = () => findButton('Re-import');
+ const findGroupDropdown = () => wrapper.findComponent(ImportGroupDropdown);
+
const findCancelButton = () => {
const buttons = wrapper
.findAllComponents(GlButton)
@@ -117,6 +121,10 @@ describe('ProviderRepoTableRow', () => {
optionalStages: OPTIONAL_STAGES,
});
});
+
+ it('does not render re-import button', () => {
+ expect(findReimportButton().exists()).toBe(false);
+ });
});
describe('when rendering importing project', () => {
@@ -200,19 +208,68 @@ describe('ProviderRepoTableRow', () => {
);
});
- it('does not renders a namespace select', () => {
- expect(wrapper.findComponent(GlDropdown).exists()).toBe(false);
+ it('does not render a namespace select', () => {
+ expect(findGroupDropdown().exists()).toBe(false);
});
it('does not render import button', () => {
expect(findImportButton().exists()).toBe(false);
});
+ it('renders re-import button', () => {
+ expect(findReimportButton().exists()).toBe(true);
+ });
+
+ it('renders namespace select after clicking re-import', async () => {
+ findReimportButton().vm.$emit('click');
+
+ await nextTick();
+
+ expect(findGroupDropdown().exists()).toBe(true);
+ });
+
+ it('imports repo when clicking re-import button', async () => {
+ findReimportButton().vm.$emit('click');
+
+ await nextTick();
+
+ findReimportButton().vm.$emit('click');
+
+ expect(fetchImport).toHaveBeenCalledWith(expect.anything(), {
+ repoId: repo.importSource.id,
+ optionalStages: {},
+ });
+ });
+
it('passes stats to import status component', () => {
expect(wrapper.findComponent(ImportStatus).props().stats).toBe(FAKE_STATS);
});
});
+ describe('when rendering failed project', () => {
+ const repo = {
+ importSource: {
+ id: 'remote-1',
+ fullName: 'fullName',
+ providerLink: 'providerLink',
+ },
+ importedProject: {
+ id: 1,
+ fullPath: 'fullPath',
+ importSource: 'importSource',
+ importStatus: STATUSES.FAILED,
+ },
+ };
+
+ beforeEach(() => {
+ mountComponent({ repo });
+ });
+
+ it('render import button', () => {
+ expect(findImportButton().exists()).toBe(true);
+ });
+ });
+
describe('when rendering incompatible project', () => {
const repo = {
importSource: {
diff --git a/spec/frontend/import_entities/import_projects/store/mutations_spec.js b/spec/frontend/import_entities/import_projects/store/mutations_spec.js
index 7884e9b4307..514a168553a 100644
--- a/spec/frontend/import_entities/import_projects/store/mutations_spec.js
+++ b/spec/frontend/import_entities/import_projects/store/mutations_spec.js
@@ -8,14 +8,14 @@ describe('import_projects store mutations', () => {
const SOURCE_PROJECT = {
id: 1,
- full_name: 'full/name',
- sanitized_name: 'name',
- provider_link: 'https://demo.link/full/name',
+ fullName: 'full/name',
+ sanitizedName: 'name',
+ providerLink: 'https://demo.link/full/name',
};
const IMPORTED_PROJECT = {
name: 'demo',
importSource: 'something',
- providerLink: 'custom-link',
+ providerLink: 'https://demo.link/full/name',
importStatus: 'status',
fullName: 'fullName',
};
@@ -64,21 +64,15 @@ describe('import_projects store mutations', () => {
describe('for imported projects', () => {
const response = {
importedProjects: [IMPORTED_PROJECT],
- providerRepos: [],
+ providerRepos: [SOURCE_PROJECT],
};
- it('recreates importSource from response', () => {
+ it('adds importedProject to relevant provider repo', () => {
state = getInitialState();
mutations[types.RECEIVE_REPOS_SUCCESS](state, response);
- expect(state.repositories[0].importSource).toStrictEqual(
- expect.objectContaining({
- fullName: IMPORTED_PROJECT.importSource,
- sanitizedName: IMPORTED_PROJECT.name,
- providerLink: IMPORTED_PROJECT.providerLink,
- }),
- );
+ expect(state.repositories[0].importedProject).toStrictEqual(IMPORTED_PROJECT);
});
it('passes project to importProject', () => {
@@ -216,13 +210,13 @@ describe('import_projects store mutations', () => {
describe(`${types.RECEIVE_IMPORT_ERROR}`, () => {
beforeEach(() => {
const REPO_ID = 1;
- state = { repositories: [{ importSource: { id: REPO_ID } }] };
+ state = { repositories: [{ importSource: { id: REPO_ID }, importedProject: {} }] };
mutations[types.RECEIVE_IMPORT_ERROR](state, REPO_ID);
});
- it(`removes importedProject entry`, () => {
- expect(state.repositories[0].importedProject).toBeNull();
+ it('sets status to failed', () => {
+ expect(state.repositories[0].importedProject.importStatus).toBe(STATUSES.FAILED);
});
});
diff --git a/spec/frontend/import_entities/import_projects/utils_spec.js b/spec/frontend/import_entities/import_projects/utils_spec.js
index d705f0acbfe..42cdf0f5a19 100644
--- a/spec/frontend/import_entities/import_projects/utils_spec.js
+++ b/spec/frontend/import_entities/import_projects/utils_spec.js
@@ -19,7 +19,7 @@ describe('import_projects utils', () => {
it.each`
status | result
${STATUSES.FINISHED} | ${false}
- ${STATUSES.FAILED} | ${false}
+ ${STATUSES.FAILED} | ${true}
${STATUSES.SCHEDULED} | ${false}
${STATUSES.STARTED} | ${false}
${STATUSES.NONE} | ${true}
diff --git a/spec/frontend/issues/dashboard/components/issues_dashboard_app_spec.js b/spec/frontend/issues/dashboard/components/issues_dashboard_app_spec.js
index db1986d1037..77d5a0579a4 100644
--- a/spec/frontend/issues/dashboard/components/issues_dashboard_app_spec.js
+++ b/spec/frontend/issues/dashboard/components/issues_dashboard_app_spec.js
@@ -120,7 +120,9 @@ describe('IssuesDashboardApp component', () => {
return waitForPromises();
});
- it('renders IssuableList component', () => {
+ // https://gitlab.com/gitlab-org/gitlab/-/issues/391722
+ // eslint-disable-next-line jest/no-disabled-tests
+ it.skip('renders IssuableList component', () => {
expect(findIssuableList().props()).toMatchObject({
currentTab: IssuableStates.Opened,
hasNextPage: true,
diff --git a/spec/frontend/vue_merge_request_widget/components/states/mr_widget_conflicts_spec.js b/spec/frontend/vue_merge_request_widget/components/states/mr_widget_conflicts_spec.js
index f13fc8a5007..2ca9dc61745 100644
--- a/spec/frontend/vue_merge_request_widget/components/states/mr_widget_conflicts_spec.js
+++ b/spec/frontend/vue_merge_request_widget/components/states/mr_widget_conflicts_spec.js
@@ -104,7 +104,6 @@ describe('MRWidgetConflicts', () => {
it('should tell you about conflicts', () => {
const text = removeBreakLine(wrapper.text()).trim();
- expect(text).toContain(mergeConflictsText);
expect(text).toContain(userCannotMergeText);
});
diff --git a/spec/graphql/resolvers/data_transfer_resolver_spec.rb b/spec/graphql/resolvers/data_transfer_resolver_spec.rb
new file mode 100644
index 00000000000..f5a088dc1c3
--- /dev/null
+++ b/spec/graphql/resolvers/data_transfer_resolver_spec.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Resolvers::DataTransferResolver, feature_category: :source_code_management do
+ include GraphqlHelpers
+
+ describe '.source' do
+ context 'with base DataTransferResolver' do
+ it 'raises NotImplementedError' do
+ expect { described_class.source }.to raise_error ::NotImplementedError
+ end
+ end
+
+ context 'with projects DataTransferResolver' do
+ let(:source) { described_class.project.source }
+
+ it 'outputs "Project"' do
+ expect(source).to eq 'Project'
+ end
+ end
+
+ context 'with groups DataTransferResolver' do
+ let(:source) { described_class.group.source }
+
+ it 'outputs "Group"' do
+ expect(source).to eq 'Group'
+ end
+ end
+ end
+end
diff --git a/spec/lib/gitlab/api_authentication/token_resolver_spec.rb b/spec/lib/gitlab/api_authentication/token_resolver_spec.rb
index 9f86b95651a..c0c8e7aba63 100644
--- a/spec/lib/gitlab/api_authentication/token_resolver_spec.rb
+++ b/spec/lib/gitlab/api_authentication/token_resolver_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Gitlab::APIAuthentication::TokenResolver do
+RSpec.describe Gitlab::APIAuthentication::TokenResolver, feature_category: :authentication_and_authorization do
let_it_be(:user) { create(:user) }
let_it_be(:project, reload: true) { create(:project, :public) }
let_it_be(:personal_access_token) { create(:personal_access_token, user: user) }
@@ -115,9 +115,9 @@ RSpec.describe Gitlab::APIAuthentication::TokenResolver do
it_behaves_like 'an unauthorized request'
end
- context 'when the external_authorization_service is enabled' do
+ context 'when the the deploy token is restricted with external_authorization' do
before do
- stub_application_setting(external_authorization_service_enabled: true)
+ allow(Gitlab::ExternalAuthorization).to receive(:allow_deploy_tokens_and_deploy_keys?).and_return(false)
end
context 'with a valid deploy token' do
diff --git a/spec/lib/gitlab/auth/auth_finders_spec.rb b/spec/lib/gitlab/auth/auth_finders_spec.rb
index d4d82f659f1..6aedd0a0a23 100644
--- a/spec/lib/gitlab/auth/auth_finders_spec.rb
+++ b/spec/lib/gitlab/auth/auth_finders_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Gitlab::Auth::AuthFinders do
+RSpec.describe Gitlab::Auth::AuthFinders, feature_category: :authentication_and_authorization do
include described_class
include HttpBasicAuthHelpers
@@ -390,9 +390,9 @@ RSpec.describe Gitlab::Auth::AuthFinders do
end
end
- context 'when the external_authorization_service is enabled' do
+ context 'when the the deploy token is restricted with external_authorization' do
before do
- stub_application_setting(external_authorization_service_enabled: true)
+ allow(Gitlab::ExternalAuthorization).to receive(:allow_deploy_tokens_and_deploy_keys?).and_return(false)
set_header(described_class::DEPLOY_TOKEN_HEADER, deploy_token.token)
end
diff --git a/spec/lib/gitlab/external_authorization/config_spec.rb b/spec/lib/gitlab/external_authorization/config_spec.rb
new file mode 100644
index 00000000000..4231b0d3747
--- /dev/null
+++ b/spec/lib/gitlab/external_authorization/config_spec.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::ExternalAuthorization::Config, feature_category: :authentication_and_authorization do
+ it 'allows deploy tokens and keys when external authorization is disabled' do
+ stub_application_setting(external_authorization_service_enabled: false)
+ expect(described_class.allow_deploy_tokens_and_deploy_keys?).to be_eql(true)
+ end
+
+ context 'when external authorization is enabled' do
+ it 'disable deploy tokens and keys' do
+ stub_application_setting(external_authorization_service_enabled: true)
+ expect(described_class.allow_deploy_tokens_and_deploy_keys?).to be_eql(false)
+ end
+
+ it "enable deploy tokens and keys when it is explicitly enabled and service url is blank" do
+ stub_application_setting(external_authorization_service_enabled: true)
+ stub_application_setting(allow_deploy_tokens_and_keys_with_external_authn: true)
+ expect(described_class.allow_deploy_tokens_and_deploy_keys?).to be_eql(true)
+ end
+ end
+end
diff --git a/spec/lib/gitlab/git_access_spec.rb b/spec/lib/gitlab/git_access_spec.rb
index 5f5ac7fff2a..ea2c239df07 100644
--- a/spec/lib/gitlab/git_access_spec.rb
+++ b/spec/lib/gitlab/git_access_spec.rb
@@ -113,9 +113,9 @@ RSpec.describe Gitlab::GitAccess, :aggregate_failures, feature_category: :authen
end
end
- context 'when the external_authorization_service is enabled' do
+ context 'when the the deploy key is restricted with external_authorization' do
before do
- stub_application_setting(external_authorization_service_enabled: true)
+ allow(Gitlab::ExternalAuthorization).to receive(:allow_deploy_tokens_and_deploy_keys?).and_return(false)
end
it 'blocks push and pull with "not found"' do
@@ -191,9 +191,9 @@ RSpec.describe Gitlab::GitAccess, :aggregate_failures, feature_category: :authen
end
end
- context 'when the external_authorization_service is enabled' do
+ context 'when the the deploy token is restricted with external_authorization' do
before do
- stub_application_setting(external_authorization_service_enabled: true)
+ allow(Gitlab::ExternalAuthorization).to receive(:allow_deploy_tokens_and_deploy_keys?).and_return(false)
end
it 'blocks pull access' do
diff --git a/spec/lib/gitlab/github_import/logger_spec.rb b/spec/lib/gitlab/github_import/logger_spec.rb
index 6fd0f5db93e..d9ffc03831e 100644
--- a/spec/lib/gitlab/github_import/logger_spec.rb
+++ b/spec/lib/gitlab/github_import/logger_spec.rb
@@ -8,18 +8,14 @@ RSpec.describe Gitlab::GithubImport::Logger do
let(:now) { Time.zone.now }
describe '#format_message' do
- before do
- allow(Labkit::Correlation::CorrelationId).to receive(:current_id).and_return('new-correlation-id')
- end
-
it 'formats strings' do
output = subject.format_message('INFO', now, 'test', 'Hello world')
- expect(Gitlab::Json.parse(output)).to eq({
+ expect(Gitlab::Json.parse(output)).to include({
'severity' => 'INFO',
'time' => now.utc.iso8601(3),
'message' => 'Hello world',
- 'correlation_id' => 'new-correlation-id',
+ 'correlation_id' => an_instance_of(String),
'feature_category' => 'importers',
'import_type' => 'github'
})
@@ -28,11 +24,11 @@ RSpec.describe Gitlab::GithubImport::Logger do
it 'formats hashes' do
output = subject.format_message('INFO', now, 'test', { hello: 1 })
- expect(Gitlab::Json.parse(output)).to eq({
+ expect(Gitlab::Json.parse(output)).to include({
'severity' => 'INFO',
'time' => now.utc.iso8601(3),
'hello' => 1,
- 'correlation_id' => 'new-correlation-id',
+ 'correlation_id' => an_instance_of(String),
'feature_category' => 'importers',
'import_type' => 'github'
})
diff --git a/spec/lib/gitlab/import/logger_spec.rb b/spec/lib/gitlab/import/logger_spec.rb
index 60978aaa25c..cf5e3a00c31 100644
--- a/spec/lib/gitlab/import/logger_spec.rb
+++ b/spec/lib/gitlab/import/logger_spec.rb
@@ -8,18 +8,14 @@ RSpec.describe Gitlab::Import::Logger do
let(:now) { Time.zone.now }
describe '#format_message' do
- before do
- allow(Labkit::Correlation::CorrelationId).to receive(:current_id).and_return('new-correlation-id')
- end
-
it 'formats strings' do
output = subject.format_message('INFO', now, 'test', 'Hello world')
- expect(Gitlab::Json.parse(output)).to eq({
+ expect(Gitlab::Json.parse(output)).to include({
'severity' => 'INFO',
'time' => now.utc.iso8601(3),
'message' => 'Hello world',
- 'correlation_id' => 'new-correlation-id',
+ 'correlation_id' => an_instance_of(String),
'feature_category' => 'importers'
})
end
@@ -27,11 +23,11 @@ RSpec.describe Gitlab::Import::Logger do
it 'formats hashes' do
output = subject.format_message('INFO', now, 'test', { hello: 1 })
- expect(Gitlab::Json.parse(output)).to eq({
+ expect(Gitlab::Json.parse(output)).to include({
'severity' => 'INFO',
'time' => now.utc.iso8601(3),
'hello' => 1,
- 'correlation_id' => 'new-correlation-id',
+ 'correlation_id' => an_instance_of(String),
'feature_category' => 'importers'
})
end
diff --git a/spec/lib/gitlab/import_export/import_export_equivalence_spec.rb b/spec/lib/gitlab/import_export/import_export_equivalence_spec.rb
index d03c21d6b4f..6c997dc1361 100644
--- a/spec/lib/gitlab/import_export/import_export_equivalence_spec.rb
+++ b/spec/lib/gitlab/import_export/import_export_equivalence_spec.rb
@@ -25,7 +25,8 @@ RSpec.describe Gitlab::ImportExport, feature_category: :importers do
end
it 'yields the initial tree when importing and exporting it again' do
- project = create(:project, creator: create(:user, :admin))
+ project = create(:project)
+ user = create(:user, :admin)
# We first generate a test fixture dynamically from a seed-fixture, so as to
# account for any fields in the initial fixture that are missing and set to
@@ -34,6 +35,7 @@ RSpec.describe Gitlab::ImportExport, feature_category: :importers do
expect(
restore_then_save_project(
project,
+ user,
import_path: seed_fixture_path,
export_path: test_fixture_path)
).to be true
@@ -42,6 +44,7 @@ RSpec.describe Gitlab::ImportExport, feature_category: :importers do
expect(
restore_then_save_project(
project,
+ user,
import_path: test_fixture_path,
export_path: test_tmp_path)
).to be true
diff --git a/spec/lib/gitlab/json_logger_spec.rb b/spec/lib/gitlab/json_logger_spec.rb
index 801de357ddc..e975fc1b128 100644
--- a/spec/lib/gitlab/json_logger_spec.rb
+++ b/spec/lib/gitlab/json_logger_spec.rb
@@ -28,10 +28,6 @@ RSpec.describe Gitlab::JsonLogger do
end
describe '#format_message' do
- before do
- allow(Labkit::Correlation::CorrelationId).to receive(:current_id).and_return('new-correlation-id')
- end
-
it 'formats strings' do
output = subject.format_message('INFO', now, 'test', 'Hello world')
data = Gitlab::Json.parse(output)
@@ -39,7 +35,7 @@ RSpec.describe Gitlab::JsonLogger do
expect(data['severity']).to eq('INFO')
expect(data['time']).to eq(now.utc.iso8601(3))
expect(data['message']).to eq('Hello world')
- expect(data['correlation_id']).to eq('new-correlation-id')
+ expect(data['correlation_id']).to be_an_instance_of(String)
end
it 'formats hashes' do
@@ -50,7 +46,7 @@ RSpec.describe Gitlab::JsonLogger do
expect(data['time']).to eq(now.utc.iso8601(3))
expect(data['hello']).to eq(1)
expect(data['message']).to be_nil
- expect(data['correlation_id']).to eq('new-correlation-id')
+ expect(data['correlation_id']).to be_an_instance_of(String)
end
end
end
diff --git a/spec/lib/gitlab/redis/multi_store_spec.rb b/spec/lib/gitlab/redis/multi_store_spec.rb
index 74b38cfa464..423a7e80ead 100644
--- a/spec/lib/gitlab/redis/multi_store_spec.rb
+++ b/spec/lib/gitlab/redis/multi_store_spec.rb
@@ -210,7 +210,7 @@ RSpec.describe Gitlab::Redis::MultiStore, feature_category: :redis do
end
end
- RSpec.shared_examples_for 'fallback read from the secondary store' do
+ RSpec.shared_examples_for 'fallback read from the non-default store' do
let(:counter) { Gitlab::Metrics::NullMetric.instance }
before do
@@ -218,7 +218,7 @@ RSpec.describe Gitlab::Redis::MultiStore, feature_category: :redis do
end
it 'fallback and execute on secondary instance' do
- expect(secondary_store).to receive(name).with(*expected_args).and_call_original
+ expect(multi_store.fallback_store).to receive(name).with(*expected_args).and_call_original
subject
end
@@ -242,7 +242,7 @@ RSpec.describe Gitlab::Redis::MultiStore, feature_category: :redis do
context 'when fallback read from the secondary instance raises an exception' do
before do
- allow(secondary_store).to receive(name).with(*expected_args).and_raise(StandardError)
+ allow(multi_store.fallback_store).to receive(name).with(*expected_args).and_raise(StandardError)
end
it 'fails with exception' do
@@ -296,7 +296,7 @@ RSpec.describe Gitlab::Redis::MultiStore, feature_category: :redis do
context 'when reading from primary instance is raising an exception' do
before do
- allow(primary_store).to receive(name).with(*expected_args).and_raise(StandardError)
+ allow(multi_store.default_store).to receive(name).with(*expected_args).and_raise(StandardError)
allow(Gitlab::ErrorTracking).to receive(:log_exception)
end
@@ -307,16 +307,16 @@ RSpec.describe Gitlab::Redis::MultiStore, feature_category: :redis do
subject
end
- include_examples 'fallback read from the secondary store'
+ include_examples 'fallback read from the non-default store'
end
- context 'when reading from empty primary instance' do
+ context 'when reading from empty default instance' do
before do
- # this ensures a cache miss without having to stub primary store
- primary_store.flushdb
+ # this ensures a cache miss without having to stub the default store
+ multi_store.default_store.flushdb
end
- include_examples 'fallback read from the secondary store'
+ include_examples 'fallback read from the non-default store'
end
context 'when the command is executed within pipelined block' do
diff --git a/spec/models/ci/group_variable_spec.rb b/spec/models/ci/group_variable_spec.rb
index fc5a9c879f6..e73319cfcd7 100644
--- a/spec/models/ci/group_variable_spec.rb
+++ b/spec/models/ci/group_variable_spec.rb
@@ -2,10 +2,13 @@
require 'spec_helper'
-RSpec.describe Ci::GroupVariable do
- subject { build(:ci_group_variable) }
+RSpec.describe Ci::GroupVariable, feature_category: :pipeline_authoring do
+ let_it_be_with_refind(:group) { create(:group) }
+
+ subject { build(:ci_group_variable, group: group) }
it_behaves_like "CI variable"
+ it_behaves_like 'includes Limitable concern'
it { is_expected.to include_module(Presentable) }
it { is_expected.to include_module(Ci::Maskable) }
diff --git a/spec/models/ci/variable_spec.rb b/spec/models/ci/variable_spec.rb
index 5f2b5971508..ce64b3ea158 100644
--- a/spec/models/ci/variable_spec.rb
+++ b/spec/models/ci/variable_spec.rb
@@ -2,10 +2,13 @@
require 'spec_helper'
-RSpec.describe Ci::Variable do
- subject { build(:ci_variable) }
+RSpec.describe Ci::Variable, feature_category: :pipeline_authoring do
+ let_it_be_with_reload(:project) { create(:project) }
+
+ subject { build(:ci_variable, project: project) }
it_behaves_like "CI variable"
+ it_behaves_like 'includes Limitable concern'
describe 'validations' do
it { is_expected.to include_module(Presentable) }
diff --git a/spec/requests/api/ci/variables_spec.rb b/spec/requests/api/ci/variables_spec.rb
index c5d01afb7c4..0f9f1bc80d6 100644
--- a/spec/requests/api/ci/variables_spec.rb
+++ b/spec/requests/api/ci/variables_spec.rb
@@ -114,73 +114,92 @@ RSpec.describe API::Ci::Variables, feature_category: :pipeline_authoring do
describe 'POST /projects/:id/variables' do
context 'authorized user with proper permissions' do
- it 'creates variable' do
- expect do
- post api("/projects/#{project.id}/variables", user), params: { key: 'TEST_VARIABLE_2', value: 'PROTECTED_VALUE_2', protected: true, masked: true, raw: true }
- end.to change { project.variables.count }.by(1)
-
- expect(response).to have_gitlab_http_status(:created)
- expect(json_response['key']).to eq('TEST_VARIABLE_2')
- expect(json_response['value']).to eq('PROTECTED_VALUE_2')
- expect(json_response['protected']).to be_truthy
- expect(json_response['masked']).to be_truthy
- expect(json_response['raw']).to be_truthy
- expect(json_response['variable_type']).to eq('env_var')
- end
+ context 'when the project is below the plan limit for variables' do
+ it 'creates variable' do
+ expect do
+ post api("/projects/#{project.id}/variables", user), params: { key: 'TEST_VARIABLE_2', value: 'PROTECTED_VALUE_2', protected: true, masked: true, raw: true }
+ end.to change { project.variables.count }.by(1)
+
+ expect(response).to have_gitlab_http_status(:created)
+ expect(json_response['key']).to eq('TEST_VARIABLE_2')
+ expect(json_response['value']).to eq('PROTECTED_VALUE_2')
+ expect(json_response['protected']).to be_truthy
+ expect(json_response['masked']).to be_truthy
+ expect(json_response['raw']).to be_truthy
+ expect(json_response['variable_type']).to eq('env_var')
+ end
- it 'masks the new value when logging' do
- masked_params = { 'key' => 'VAR_KEY', 'value' => '[FILTERED]', 'protected' => 'true', 'masked' => 'true' }
+ it 'masks the new value when logging' do
+ masked_params = { 'key' => 'VAR_KEY', 'value' => '[FILTERED]', 'protected' => 'true', 'masked' => 'true' }
- expect(::API::API::LOGGER).to receive(:info).with(include(params: include(masked_params)))
+ expect(::API::API::LOGGER).to receive(:info).with(include(params: include(masked_params)))
- post api("/projects/#{project.id}/variables", user),
- params: { key: 'VAR_KEY', value: 'SENSITIVE', protected: true, masked: true }
- end
+ post api("/projects/#{project.id}/variables", user),
+ params: { key: 'VAR_KEY', value: 'SENSITIVE', protected: true, masked: true }
+ end
- it 'creates variable with optional attributes' do
- expect do
- post api("/projects/#{project.id}/variables", user), params: { variable_type: 'file', key: 'TEST_VARIABLE_2', value: 'VALUE_2' }
- end.to change { project.variables.count }.by(1)
-
- expect(response).to have_gitlab_http_status(:created)
- expect(json_response['key']).to eq('TEST_VARIABLE_2')
- expect(json_response['value']).to eq('VALUE_2')
- expect(json_response['protected']).to be_falsey
- expect(json_response['masked']).to be_falsey
- expect(json_response['raw']).to be_falsey
- expect(json_response['variable_type']).to eq('file')
- end
+ it 'creates variable with optional attributes' do
+ expect do
+ post api("/projects/#{project.id}/variables", user), params: { variable_type: 'file', key: 'TEST_VARIABLE_2', value: 'VALUE_2' }
+ end.to change { project.variables.count }.by(1)
+
+ expect(response).to have_gitlab_http_status(:created)
+ expect(json_response['key']).to eq('TEST_VARIABLE_2')
+ expect(json_response['value']).to eq('VALUE_2')
+ expect(json_response['protected']).to be_falsey
+ expect(json_response['masked']).to be_falsey
+ expect(json_response['raw']).to be_falsey
+ expect(json_response['variable_type']).to eq('file')
+ end
- it 'does not allow to duplicate variable key' do
- expect do
- post api("/projects/#{project.id}/variables", user), params: { key: variable.key, value: 'VALUE_2' }
- end.to change { project.variables.count }.by(0)
+ it 'does not allow to duplicate variable key' do
+ expect do
+ post api("/projects/#{project.id}/variables", user), params: { key: variable.key, value: 'VALUE_2' }
+ end.to change { project.variables.count }.by(0)
- expect(response).to have_gitlab_http_status(:bad_request)
- end
+ expect(response).to have_gitlab_http_status(:bad_request)
+ end
- it 'creates variable with a specific environment scope' do
- expect do
- post api("/projects/#{project.id}/variables", user), params: { key: 'TEST_VARIABLE_2', value: 'VALUE_2', environment_scope: 'review/*' }
- end.to change { project.variables.reload.count }.by(1)
+ it 'creates variable with a specific environment scope' do
+ expect do
+ post api("/projects/#{project.id}/variables", user), params: { key: 'TEST_VARIABLE_2', value: 'VALUE_2', environment_scope: 'review/*' }
+ end.to change { project.variables.reload.count }.by(1)
+
+ expect(response).to have_gitlab_http_status(:created)
+ expect(json_response['key']).to eq('TEST_VARIABLE_2')
+ expect(json_response['value']).to eq('VALUE_2')
+ expect(json_response['environment_scope']).to eq('review/*')
+ end
+
+ it 'allows duplicated variable key given different environment scopes' do
+ variable = create(:ci_variable, project: project)
- expect(response).to have_gitlab_http_status(:created)
- expect(json_response['key']).to eq('TEST_VARIABLE_2')
- expect(json_response['value']).to eq('VALUE_2')
- expect(json_response['environment_scope']).to eq('review/*')
+ expect do
+ post api("/projects/#{project.id}/variables", user), params: { key: variable.key, value: 'VALUE_2', environment_scope: 'review/*' }
+ end.to change { project.variables.reload.count }.by(1)
+
+ expect(response).to have_gitlab_http_status(:created)
+ expect(json_response['key']).to eq(variable.key)
+ expect(json_response['value']).to eq('VALUE_2')
+ expect(json_response['environment_scope']).to eq('review/*')
+ end
end
- it 'allows duplicated variable key given different environment scopes' do
- variable = create(:ci_variable, project: project)
+ context 'when the project is at the plan limit for variables' do
+ before do
+ create(:plan_limits, :default_plan, project_ci_variables: 1)
+ end
- expect do
- post api("/projects/#{project.id}/variables", user), params: { key: variable.key, value: 'VALUE_2', environment_scope: 'review/*' }
- end.to change { project.variables.reload.count }.by(1)
+ it 'returns a variable limit error' do
+ expect do
+ post api("/projects/#{project.id}/variables", user), params: { key: 'TOO_MANY_VARS', value: 'too many' }
+ end.not_to change { project.variables.count }
- expect(response).to have_gitlab_http_status(:created)
- expect(json_response['key']).to eq(variable.key)
- expect(json_response['value']).to eq('VALUE_2')
- expect(json_response['environment_scope']).to eq('review/*')
+ expect(response).to have_gitlab_http_status(:bad_request)
+ expect(json_response['message']['base']).to contain_exactly(
+ 'Maximum number of project ci variables (1) exceeded'
+ )
+ end
end
end
diff --git a/spec/requests/api/draft_notes_spec.rb b/spec/requests/api/draft_notes_spec.rb
index b8331e072cf..e8f519e004d 100644
--- a/spec/requests/api/draft_notes_spec.rb
+++ b/spec/requests/api/draft_notes_spec.rb
@@ -12,6 +12,8 @@ RSpec.describe API::DraftNotes, feature_category: :code_review_workflow do
let!(:draft_note_by_current_user) { create(:draft_note, merge_request: merge_request, author: user) }
let!(:draft_note_by_random_user) { create(:draft_note, merge_request: merge_request) }
+ let_it_be(:api_stub) { "/projects/#{project.id}/merge_requests/#{merge_request.iid}" }
+
before do
project.add_developer(user)
end
@@ -117,4 +119,60 @@ RSpec.describe API::DraftNotes, feature_category: :code_review_workflow do
end
end
end
+
+ describe "Publishing a draft note" do
+ let(:publish_draft_note) do
+ put api(
+ "#{api_stub}/draft_notes/#{draft_note_by_current_user.id}/publish",
+ user
+ )
+ end
+
+ context "when publishing an existing draft note by the user" do
+ it "returns 204 No Content status" do
+ publish_draft_note
+
+ expect(response).to have_gitlab_http_status(:no_content)
+ end
+
+ it "publishes the specified draft note" do
+ expect { publish_draft_note }.to change { Note.count }.by(1)
+ expect(DraftNote.exists?(draft_note_by_current_user.id)).to eq(false)
+ end
+ end
+
+ context "when publishing a non-existent draft note" do
+ it "returns a 404 Not Found" do
+ put api(
+ "#{api_stub}/draft_notes/#{non_existing_record_id}/publish",
+ user
+ )
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
+
+ context "when publishing a draft note by a different user" do
+ it "returns a 404 Not Found" do
+ put api(
+ "#{api_stub}/draft_notes/#{draft_note_by_random_user.id}/publish",
+ user
+ )
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
+
+ context "when DraftNotes::PublishService returns a non-success" do
+ it "returns an :internal_server_error and a message" do
+ expect_next_instance_of(DraftNotes::PublishService) do |instance|
+ expect(instance).to receive(:execute).and_return({ status: :failure, message: "Error message" })
+ end
+
+ publish_draft_note
+
+ expect(response).to have_gitlab_http_status(:internal_server_error)
+ end
+ end
+ end
end
diff --git a/spec/requests/api/group_variables_spec.rb b/spec/requests/api/group_variables_spec.rb
index 90b9606ec7b..e3d538d72ba 100644
--- a/spec/requests/api/group_variables_spec.rb
+++ b/spec/requests/api/group_variables_spec.rb
@@ -88,51 +88,70 @@ RSpec.describe API::GroupVariables, feature_category: :pipeline_authoring do
context 'authorized user with proper permissions' do
let(:access_level) { :owner }
- it 'creates variable' do
- expect do
- post api("/groups/#{group.id}/variables", user), params: { key: 'TEST_VARIABLE_2', value: 'PROTECTED_VALUE_2', protected: true, masked: true, raw: true }
- end.to change { group.variables.count }.by(1)
-
- expect(response).to have_gitlab_http_status(:created)
- expect(json_response['key']).to eq('TEST_VARIABLE_2')
- expect(json_response['value']).to eq('PROTECTED_VALUE_2')
- expect(json_response['protected']).to be_truthy
- expect(json_response['masked']).to be_truthy
- expect(json_response['variable_type']).to eq('env_var')
- expect(json_response['environment_scope']).to eq('*')
- expect(json_response['raw']).to be_truthy
+ context 'when the group is below the plan limit for variables' do
+ it 'creates variable' do
+ expect do
+ post api("/groups/#{group.id}/variables", user), params: { key: 'TEST_VARIABLE_2', value: 'PROTECTED_VALUE_2', protected: true, masked: true, raw: true }
+ end.to change { group.variables.count }.by(1)
+
+ expect(response).to have_gitlab_http_status(:created)
+ expect(json_response['key']).to eq('TEST_VARIABLE_2')
+ expect(json_response['value']).to eq('PROTECTED_VALUE_2')
+ expect(json_response['protected']).to be_truthy
+ expect(json_response['masked']).to be_truthy
+ expect(json_response['variable_type']).to eq('env_var')
+ expect(json_response['environment_scope']).to eq('*')
+ expect(json_response['raw']).to be_truthy
+ end
+
+ it 'masks the new value when logging' do
+ masked_params = { 'key' => 'VAR_KEY', 'value' => '[FILTERED]', 'protected' => 'true', 'masked' => 'true' }
+
+ expect(::API::API::LOGGER).to receive(:info).with(include(params: include(masked_params)))
+
+ post api("/groups/#{group.id}/variables", user),
+ params: { key: 'VAR_KEY', value: 'SENSITIVE', protected: true, masked: true }
+ end
+
+ it 'creates variable with optional attributes' do
+ expect do
+ post api("/groups/#{group.id}/variables", user), params: { variable_type: 'file', key: 'TEST_VARIABLE_2', value: 'VALUE_2' }
+ end.to change { group.variables.count }.by(1)
+
+ expect(response).to have_gitlab_http_status(:created)
+ expect(json_response['key']).to eq('TEST_VARIABLE_2')
+ expect(json_response['value']).to eq('VALUE_2')
+ expect(json_response['protected']).to be_falsey
+ expect(json_response['masked']).to be_falsey
+ expect(json_response['raw']).to be_falsey
+ expect(json_response['variable_type']).to eq('file')
+ expect(json_response['environment_scope']).to eq('*')
+ end
+
+ it 'does not allow to duplicate variable key' do
+ expect do
+ post api("/groups/#{group.id}/variables", user), params: { key: variable.key, value: 'VALUE_2' }
+ end.to change { group.variables.count }.by(0)
+
+ expect(response).to have_gitlab_http_status(:bad_request)
+ end
end
- it 'masks the new value when logging' do
- masked_params = { 'key' => 'VAR_KEY', 'value' => '[FILTERED]', 'protected' => 'true', 'masked' => 'true' }
-
- expect(::API::API::LOGGER).to receive(:info).with(include(params: include(masked_params)))
-
- post api("/groups/#{group.id}/variables", user),
- params: { key: 'VAR_KEY', value: 'SENSITIVE', protected: true, masked: true }
- end
-
- it 'creates variable with optional attributes' do
- expect do
- post api("/groups/#{group.id}/variables", user), params: { variable_type: 'file', key: 'TEST_VARIABLE_2', value: 'VALUE_2' }
- end.to change { group.variables.count }.by(1)
-
- expect(response).to have_gitlab_http_status(:created)
- expect(json_response['key']).to eq('TEST_VARIABLE_2')
- expect(json_response['value']).to eq('VALUE_2')
- expect(json_response['protected']).to be_falsey
- expect(json_response['masked']).to be_falsey
- expect(json_response['raw']).to be_falsey
- expect(json_response['variable_type']).to eq('file')
- expect(json_response['environment_scope']).to eq('*')
- end
-
- it 'does not allow to duplicate variable key' do
- expect do
- post api("/groups/#{group.id}/variables", user), params: { key: variable.key, value: 'VALUE_2' }
- end.to change { group.variables.count }.by(0)
-
- expect(response).to have_gitlab_http_status(:bad_request)
+ context 'when the group is at the plan limit for variables' do
+ before do
+ create(:plan_limits, :default_plan, group_ci_variables: 1)
+ end
+
+ it 'returns a variable limit error' do
+ expect do
+ post api("/groups/#{group.id}/variables", user), params: { key: 'TOO_MANY_VARS', value: 'too many' }
+ end.not_to change { group.variables.count }
+
+ expect(response).to have_gitlab_http_status(:bad_request)
+ expect(json_response['message']['base']).to contain_exactly(
+ 'Maximum number of group ci variables (1) exceeded'
+ )
+ end
end
end
diff --git a/spec/serializers/issue_entity_spec.rb b/spec/serializers/issue_entity_spec.rb
index cc3635a0afc..06d8523b2e7 100644
--- a/spec/serializers/issue_entity_spec.rb
+++ b/spec/serializers/issue_entity_spec.rb
@@ -97,7 +97,7 @@ RSpec.describe IssueEntity do
before do
Issues::DuplicateService
- .new(project: project, current_user: member)
+ .new(container: project, current_user: member)
.execute(issue, new_issue)
end
diff --git a/spec/services/issues/after_create_service_spec.rb b/spec/services/issues/after_create_service_spec.rb
index 6b720d6e687..39a6799dbad 100644
--- a/spec/services/issues/after_create_service_spec.rb
+++ b/spec/services/issues/after_create_service_spec.rb
@@ -11,7 +11,7 @@ RSpec.describe Issues::AfterCreateService do
let_it_be(:milestone) { create(:milestone, project: project) }
let_it_be(:issue) { create(:issue, project: project, author: current_user, milestone: milestone, assignee_ids: [assignee.id]) }
- subject(:after_create_service) { described_class.new(project: project, current_user: current_user) }
+ subject(:after_create_service) { described_class.new(container: project, current_user: current_user) }
describe '#execute' do
it 'creates a pending todo for new assignee' do
diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb
index ef24d1e940e..803808e667c 100644
--- a/spec/services/issues/close_service_spec.rb
+++ b/spec/services/issues/close_service_spec.rb
@@ -20,13 +20,13 @@ RSpec.describe Issues::CloseService do
end
describe '#execute' do
- let(:service) { described_class.new(project: project, current_user: user) }
+ let(:service) { described_class.new(container: project, current_user: user) }
context 'when skip_authorization is true' do
it 'does close the issue even if user is not authorized' do
non_authorized_user = create(:user)
- service = described_class.new(project: project, current_user: non_authorized_user)
+ service = described_class.new(container: project, current_user: non_authorized_user)
expect do
service.execute(issue, skip_authorization: true)
@@ -167,7 +167,7 @@ RSpec.describe Issues::CloseService do
project.reload
expect(project.external_issue_tracker).to receive(:close_issue)
- described_class.new(project: project, current_user: user).close_issue(external_issue)
+ described_class.new(container: project, current_user: user).close_issue(external_issue)
end
end
@@ -178,7 +178,7 @@ RSpec.describe Issues::CloseService do
project.reload
expect(project.external_issue_tracker).not_to receive(:close_issue)
- described_class.new(project: project, current_user: user).close_issue(external_issue)
+ described_class.new(container: project, current_user: user).close_issue(external_issue)
end
end
@@ -189,7 +189,7 @@ RSpec.describe Issues::CloseService do
project.reload
expect(project.external_issue_tracker).not_to receive(:close_issue)
- described_class.new(project: project, current_user: user).close_issue(external_issue)
+ described_class.new(container: project, current_user: user).close_issue(external_issue)
end
end
end
@@ -197,7 +197,7 @@ RSpec.describe Issues::CloseService do
context "closed by a merge request", :sidekiq_might_not_need_inline do
subject(:close_issue) do
perform_enqueued_jobs do
- described_class.new(project: project, current_user: user).close_issue(issue, closed_via: closing_merge_request)
+ described_class.new(container: project, current_user: user).close_issue(issue, closed_via: closing_merge_request)
end
end
@@ -266,7 +266,7 @@ RSpec.describe Issues::CloseService do
context "closed by a commit", :sidekiq_might_not_need_inline do
it 'mentions closure via a commit' do
perform_enqueued_jobs do
- described_class.new(project: project, current_user: user).close_issue(issue, closed_via: closing_commit)
+ described_class.new(container: project, current_user: user).close_issue(issue, closed_via: closing_commit)
end
email = ActionMailer::Base.deliveries.last
@@ -280,7 +280,7 @@ RSpec.describe Issues::CloseService do
it 'does not mention the commit id' do
project.project_feature.update_attribute(:repository_access_level, ProjectFeature::DISABLED)
perform_enqueued_jobs do
- described_class.new(project: project, current_user: user).close_issue(issue, closed_via: closing_commit)
+ described_class.new(container: project, current_user: user).close_issue(issue, closed_via: closing_commit)
end
email = ActionMailer::Base.deliveries.last
@@ -296,7 +296,7 @@ RSpec.describe Issues::CloseService do
context "valid params" do
subject(:close_issue) do
perform_enqueued_jobs do
- described_class.new(project: project, current_user: user).close_issue(issue)
+ described_class.new(container: project, current_user: user).close_issue(issue)
end
end
@@ -438,7 +438,7 @@ RSpec.describe Issues::CloseService do
expect(project).to receive(:execute_hooks).with(expected_payload, :issue_hooks)
expect(project).to receive(:execute_integrations).with(expected_payload, :issue_hooks)
- described_class.new(project: project, current_user: user).close_issue(issue)
+ described_class.new(container: project, current_user: user).close_issue(issue)
end
end
@@ -449,7 +449,7 @@ RSpec.describe Issues::CloseService do
expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks)
expect(project).to receive(:execute_integrations).with(an_instance_of(Hash), :confidential_issue_hooks)
- described_class.new(project: project, current_user: user).close_issue(issue)
+ described_class.new(container: project, current_user: user).close_issue(issue)
end
end
diff --git a/spec/services/issues/duplicate_service_spec.rb b/spec/services/issues/duplicate_service_spec.rb
index 0eb0bbb1480..f49bce70cd0 100644
--- a/spec/services/issues/duplicate_service_spec.rb
+++ b/spec/services/issues/duplicate_service_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe Issues::DuplicateService do
let(:canonical_issue) { create(:issue, project: canonical_project) }
let(:duplicate_issue) { create(:issue, project: duplicate_project) }
- subject { described_class.new(project: duplicate_project, current_user: user) }
+ subject { described_class.new(container: duplicate_project, current_user: user) }
describe '#execute' do
context 'when the issues passed are the same' do
diff --git a/spec/services/issues/referenced_merge_requests_service_spec.rb b/spec/services/issues/referenced_merge_requests_service_spec.rb
index 16166c1fa33..aee3583b834 100644
--- a/spec/services/issues/referenced_merge_requests_service_spec.rb
+++ b/spec/services/issues/referenced_merge_requests_service_spec.rb
@@ -26,7 +26,7 @@ RSpec.describe Issues::ReferencedMergeRequestsService do
let_it_be(:referencing_mr) { create_referencing_mr(source_project: project, source_branch: 'csv') }
let_it_be(:referencing_mr_other_project) { create_referencing_mr(source_project: other_project, source_branch: 'csv') }
- let(:service) { described_class.new(project: project, current_user: user) }
+ let(:service) { described_class.new(container: project, current_user: user) }
describe '#execute' do
it 'returns a list of sorted merge requests' do
diff --git a/spec/services/issues/related_branches_service_spec.rb b/spec/services/issues/related_branches_service_spec.rb
index 95d456c1b05..05c61d0abfc 100644
--- a/spec/services/issues/related_branches_service_spec.rb
+++ b/spec/services/issues/related_branches_service_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe Issues::RelatedBranchesService do
let(:user) { developer }
- subject { described_class.new(project: project, current_user: user) }
+ subject { described_class.new(container: project, current_user: user) }
before_all do
project.add_developer(developer)
@@ -54,7 +54,7 @@ RSpec.describe Issues::RelatedBranchesService do
merge_request.create_cross_references!(user)
referenced_merge_requests = Issues::ReferencedMergeRequestsService
- .new(project: issue.project, current_user: user)
+ .new(container: issue.project, current_user: user)
.referenced_merge_requests(issue)
expect(referenced_merge_requests).not_to be_empty
diff --git a/spec/services/issues/reopen_service_spec.rb b/spec/services/issues/reopen_service_spec.rb
index 529b3ff266b..68015a2327e 100644
--- a/spec/services/issues/reopen_service_spec.rb
+++ b/spec/services/issues/reopen_service_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe Issues::ReopenService do
guest = create(:user)
project.add_guest(guest)
- described_class.new(project: project, current_user: guest).execute(issue)
+ described_class.new(container: project, current_user: guest).execute(issue)
expect(issue).to be_closed
end
@@ -21,7 +21,7 @@ RSpec.describe Issues::ReopenService do
it 'does close the issue even if user is not authorized' do
non_authorized_user = create(:user)
- service = described_class.new(project: project, current_user: non_authorized_user)
+ service = described_class.new(container: project, current_user: non_authorized_user)
expect do
service.execute(issue, skip_authorization: true)
@@ -33,7 +33,7 @@ RSpec.describe Issues::ReopenService do
context 'when user is authorized to reopen issue' do
let(:user) { create(:user) }
- subject(:execute) { described_class.new(project: project, current_user: user).execute(issue) }
+ subject(:execute) { described_class.new(container: project, current_user: user).execute(issue) }
before do
project.add_maintainer(user)
diff --git a/spec/services/issues/reorder_service_spec.rb b/spec/services/issues/reorder_service_spec.rb
index 392930c1b9f..430a9e9f526 100644
--- a/spec/services/issues/reorder_service_spec.rb
+++ b/spec/services/issues/reorder_service_spec.rb
@@ -85,6 +85,6 @@ RSpec.describe Issues::ReorderService do
end
def service(params)
- described_class.new(project: project, current_user: user, params: params)
+ described_class.new(container: project, current_user: user, params: params)
end
end
diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb
index f1859b2208c..973025bd2e3 100644
--- a/spec/services/issues/update_service_spec.rb
+++ b/spec/services/issues/update_service_spec.rb
@@ -45,7 +45,7 @@ RSpec.describe Issues::UpdateService, :mailer do
end
def update_issue(opts)
- described_class.new(project: project, current_user: user, params: opts).execute(issue)
+ described_class.new(container: project, current_user: user, params: opts).execute(issue)
end
it_behaves_like 'issuable update service updating last_edited_at values' do
@@ -420,7 +420,7 @@ RSpec.describe Issues::UpdateService, :mailer do
opts[:move_between_ids] = [issue_1.id, issue_2.id]
- described_class.new(project: issue_3.project, current_user: user, params: opts).execute(issue_3)
+ described_class.new(container: issue_3.project, current_user: user, params: opts).execute(issue_3)
expect(issue_2.relative_position).to be_between(issue_1.relative_position, issue_2.relative_position)
end
end
@@ -428,7 +428,7 @@ RSpec.describe Issues::UpdateService, :mailer do
context 'when current user cannot admin issues in the project' do
it 'filters out params that cannot be set without the :admin_issue permission' do
described_class.new(
- project: project, current_user: guest, params: opts.merge(
+ container: project, current_user: guest, params: opts.merge(
confidential: true,
issue_type: 'test_case'
)
@@ -838,7 +838,7 @@ RSpec.describe Issues::UpdateService, :mailer do
opts = { label_ids: [label.id] }
perform_enqueued_jobs do
- @issue = described_class.new(project: project, current_user: user, params: opts).execute(issue)
+ @issue = described_class.new(container: project, current_user: user, params: opts).execute(issue)
end
should_email(subscriber)
@@ -854,7 +854,7 @@ RSpec.describe Issues::UpdateService, :mailer do
opts = { label_ids: [label.id, label2.id] }
perform_enqueued_jobs do
- @issue = described_class.new(project: project, current_user: user, params: opts).execute(issue)
+ @issue = described_class.new(container: project, current_user: user, params: opts).execute(issue)
end
should_not_email(subscriber)
@@ -865,7 +865,7 @@ RSpec.describe Issues::UpdateService, :mailer do
opts = { label_ids: [label2.id] }
perform_enqueued_jobs do
- @issue = described_class.new(project: project, current_user: user, params: opts).execute(issue)
+ @issue = described_class.new(container: project, current_user: user, params: opts).execute(issue)
end
should_not_email(subscriber)
@@ -897,7 +897,7 @@ RSpec.describe Issues::UpdateService, :mailer do
line_number: 1
}
}
- service = described_class.new(project: project, current_user: user, params: params)
+ service = described_class.new(container: project, current_user: user, params: params)
expect(Spam::SpamActionService).not_to receive(:new)
@@ -915,7 +915,7 @@ RSpec.describe Issues::UpdateService, :mailer do
line_number: 1
}
}
- service = described_class.new(project: project, current_user: user, params: params)
+ service = described_class.new(container: project, current_user: user, params: params)
expect(service).to receive(:after_update).with(issue, {})
@@ -991,7 +991,7 @@ RSpec.describe Issues::UpdateService, :mailer do
context 'updating labels' do
let(:label3) { create(:label, project: project) }
- let(:result) { described_class.new(project: project, current_user: user, params: params).execute(issue).reload }
+ let(:result) { described_class.new(container: project, current_user: user, params: params).execute(issue).reload }
context 'when add_label_ids and label_ids are passed' do
let(:params) { { label_ids: [label.id], add_label_ids: [label3.id] } }
@@ -1063,7 +1063,7 @@ RSpec.describe Issues::UpdateService, :mailer do
end
context 'updating dates' do
- subject(:result) { described_class.new(project: project, current_user: user, params: params).execute(issue) }
+ subject(:result) { described_class.new(container: project, current_user: user, params: params).execute(issue) }
let(:updated_date) { 1.week.from_now.to_date }
@@ -1428,7 +1428,7 @@ RSpec.describe Issues::UpdateService, :mailer do
it 'raises an error for invalid move ids' do
opts = { move_between_ids: [9000, non_existing_record_id] }
- expect { described_class.new(project: issue.project, current_user: user, params: opts).execute(issue) }
+ expect { described_class.new(container: issue.project, current_user: user, params: opts).execute(issue) }
.to raise_error(ActiveRecord::RecordNotFound)
end
end
@@ -1473,7 +1473,7 @@ RSpec.describe Issues::UpdateService, :mailer do
it_behaves_like 'issuable record that supports quick actions' do
let(:existing_issue) { create(:issue, project: project) }
- let(:issuable) { described_class.new(project: project, current_user: user, params: params).execute(existing_issue) }
+ let(:issuable) { described_class.new(container: project, current_user: user, params: params).execute(existing_issue) }
end
context 'with quick actions' do
diff --git a/spec/services/issues/zoom_link_service_spec.rb b/spec/services/issues/zoom_link_service_spec.rb
index ad1f91ab5e6..230e4c1b5e1 100644
--- a/spec/services/issues/zoom_link_service_spec.rb
+++ b/spec/services/issues/zoom_link_service_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe Issues::ZoomLinkService do
let_it_be(:issue) { create(:issue) }
let(:project) { issue.project }
- let(:service) { described_class.new(project: project, current_user: user, params: { issue: issue }) }
+ let(:service) { described_class.new(container: project, current_user: user, params: { issue: issue }) }
let(:zoom_link) { 'https://zoom.us/j/123456789' }
before do
diff --git a/spec/services/tasks_to_be_done/base_service_spec.rb b/spec/services/tasks_to_be_done/base_service_spec.rb
index 8ea9a6a8ec2..cfeff36cc0d 100644
--- a/spec/services/tasks_to_be_done/base_service_spec.rb
+++ b/spec/services/tasks_to_be_done/base_service_spec.rb
@@ -58,7 +58,7 @@ RSpec.describe TasksToBeDone::BaseService do
expect(Issues::UpdateService)
.to receive(:new)
- .with(project: project, current_user: current_user, params: params)
+ .with(container: project, current_user: current_user, params: params)
.and_call_original
expect { service.execute }.not_to change(Issue, :count)
diff --git a/spec/services/work_items/update_service_spec.rb b/spec/services/work_items/update_service_spec.rb
index 87665bcad2c..435995c6570 100644
--- a/spec/services/work_items/update_service_spec.rb
+++ b/spec/services/work_items/update_service_spec.rb
@@ -22,7 +22,7 @@ RSpec.describe WorkItems::UpdateService do
describe '#execute' do
let(:service) do
described_class.new(
- project: project,
+ container: project,
current_user: current_user,
params: opts,
spam_params: spam_params,
@@ -146,7 +146,7 @@ RSpec.describe WorkItems::UpdateService do
let(:service) do
described_class.new(
- project: project,
+ container: project,
current_user: current_user,
params: opts,
spam_params: spam_params,
@@ -362,7 +362,7 @@ RSpec.describe WorkItems::UpdateService do
def update_issuable(update_params)
described_class.new(
- project: project,
+ container: project,
current_user: current_user,
params: update_params,
spam_params: spam_params,
diff --git a/spec/support/helpers/cycle_analytics_helpers.rb b/spec/support/helpers/cycle_analytics_helpers.rb
index 632f3ea28ee..eba5771e062 100644
--- a/spec/support/helpers/cycle_analytics_helpers.rb
+++ b/spec/support/helpers/cycle_analytics_helpers.rb
@@ -185,7 +185,7 @@ module CycleAnalyticsHelpers
def merge_merge_requests_closing_issue(user, project, issue)
merge_requests = Issues::ReferencedMergeRequestsService
- .new(project: project, current_user: user)
+ .new(container: project, current_user: user)
.closed_by_merge_requests(issue)
merge_requests.each { |merge_request| MergeRequests::MergeService.new(project: project, current_user: user, params: { sha: merge_request.diff_head_sha }).execute(merge_request) }
diff --git a/spec/support/import_export/common_util.rb b/spec/support/import_export/common_util.rb
index 3d7a0d29e71..f8f32fa59d1 100644
--- a/spec/support/import_export/common_util.rb
+++ b/spec/support/import_export/common_util.rb
@@ -51,22 +51,22 @@ module ImportExport
json
end
- def restore_then_save_project(project, import_path:, export_path:)
- project_restorer = get_project_restorer(project, import_path)
- project_saver = get_project_saver(project, export_path)
+ def restore_then_save_project(project, user, import_path:, export_path:)
+ project_restorer = get_project_restorer(project, user, import_path)
+ project_saver = get_project_saver(project, user, export_path)
project_restorer.restore && project_saver.save
end
- def get_project_restorer(project, import_path)
+ def get_project_restorer(project, user, import_path)
Gitlab::ImportExport::Project::TreeRestorer.new(
- user: project.creator, shared: get_shared_env(path: import_path), project: project
+ user: user, shared: get_shared_env(path: import_path), project: project
)
end
- def get_project_saver(project, export_path)
+ def get_project_saver(project, user, export_path)
Gitlab::ImportExport::Project::TreeSaver.new(
- project: project, current_user: project.creator, shared: get_shared_env(path: export_path)
+ project: project, current_user: user, shared: get_shared_env(path: export_path)
)
end
diff --git a/spec/support/services/issuable_update_service_shared_examples.rb b/spec/support/services/issuable_update_service_shared_examples.rb
index b85c3904127..feea21be428 100644
--- a/spec/support/services/issuable_update_service_shared_examples.rb
+++ b/spec/support/services/issuable_update_service_shared_examples.rb
@@ -26,7 +26,7 @@ RSpec.shared_examples 'issuable update service' do
expect(project).to receive(:execute_hooks).with(expected_payload, hook_event)
expect(project).to receive(:execute_integrations).with(expected_payload, hook_event)
- described_class.new(project: project, current_user: user, params: { state_event: 'reopen' }).execute(closed_issuable)
+ described_class.new(**described_class.constructor_container_arg(project), current_user: user, params: { state_event: 'reopen' }).execute(closed_issuable)
end
end
@@ -48,7 +48,7 @@ RSpec.shared_examples 'issuable update service' do
expect(project).to receive(:execute_hooks).with(expected_payload, hook_event)
expect(project).to receive(:execute_integrations).with(expected_payload, hook_event)
- described_class.new(project: project, current_user: user, params: { state_event: 'close' }).execute(open_issuable)
+ described_class.new(**described_class.constructor_container_arg(project), current_user: user, params: { state_event: 'close' }).execute(open_issuable)
end
end
end
diff --git a/spec/support/shared_examples/features/work_items_shared_examples.rb b/spec/support/shared_examples/features/work_items_shared_examples.rb
index 61a9c2e8aea..4f3d957ad71 100644
--- a/spec/support/shared_examples/features/work_items_shared_examples.rb
+++ b/spec/support/shared_examples/features/work_items_shared_examples.rb
@@ -106,7 +106,7 @@ RSpec.shared_examples 'work items description' do
wait_for_requests
::WorkItems::UpdateService.new(
- project: work_item.project,
+ container: work_item.project,
current_user: other_user,
params: { description: "oh no!" }
).execute(work_item)
diff --git a/spec/support/shared_examples/requests/api/time_tracking_shared_examples.rb b/spec/support/shared_examples/requests/api/time_tracking_shared_examples.rb
index 381583ff2a9..86a1fd76d09 100644
--- a/spec/support/shared_examples/requests/api/time_tracking_shared_examples.rb
+++ b/spec/support/shared_examples/requests/api/time_tracking_shared_examples.rb
@@ -142,7 +142,7 @@ RSpec.shared_examples 'time tracking endpoints' do |issuable_name|
if issuable_name == 'issue'
it 'calls update service without :use_specialized_service param' do
expect(::Issues::UpdateService).to receive(:new).with(
- project: project,
+ container: project,
current_user: user,
params: { spend_time: { duration: 3600, summary: 'summary', user_id: user.id } })
diff --git a/spec/support/shared_examples/services/issuable_shared_examples.rb b/spec/support/shared_examples/services/issuable_shared_examples.rb
index 142d4ae8531..fe868d494d2 100644
--- a/spec/support/shared_examples/services/issuable_shared_examples.rb
+++ b/spec/support/shared_examples/services/issuable_shared_examples.rb
@@ -11,7 +11,8 @@ end
RSpec.shared_examples 'updating a single task' do
def update_issuable(opts)
issuable = try(:issue) || try(:merge_request)
- described_class.new(project: project, current_user: user, params: opts).execute(issuable)
+ described_class.new(**described_class.constructor_container_arg(project), current_user: user, params: opts)
+ .execute(issuable)
end
before do
diff --git a/spec/support/shared_examples/services/updating_mentions_shared_examples.rb b/spec/support/shared_examples/services/updating_mentions_shared_examples.rb
index 13a2aa9ddac..0f649173683 100644
--- a/spec/support/shared_examples/services/updating_mentions_shared_examples.rb
+++ b/spec/support/shared_examples/services/updating_mentions_shared_examples.rb
@@ -15,7 +15,8 @@ RSpec.shared_examples 'updating mentions' do |service_class|
def update_mentionable(opts)
perform_enqueued_jobs do
- service_class.new(project: project, current_user: user, params: opts).execute(mentionable)
+ service_class.new(**service_class.constructor_container_arg(project),
+ current_user: user, params: opts).execute(mentionable)
end
mentionable.reload
diff --git a/spec/workers/incident_management/close_incident_worker_spec.rb b/spec/workers/incident_management/close_incident_worker_spec.rb
index c96bb4a3d1e..145ee780573 100644
--- a/spec/workers/incident_management/close_incident_worker_spec.rb
+++ b/spec/workers/incident_management/close_incident_worker_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe IncidentManagement::CloseIncidentWorker do
let(:issue_id) { issue.id }
it 'calls the close issue service' do
- expect_next_instance_of(Issues::CloseService, project: project, current_user: user) do |service|
+ expect_next_instance_of(Issues::CloseService, container: project, current_user: user) do |service|
expect(service).to receive(:execute).with(issue, system_note: false).and_call_original
end
diff --git a/spec/workers/issues/close_worker_spec.rb b/spec/workers/issues/close_worker_spec.rb
index 41611447db1..3902618ae03 100644
--- a/spec/workers/issues/close_worker_spec.rb
+++ b/spec/workers/issues/close_worker_spec.rb
@@ -29,7 +29,7 @@ RSpec.describe Issues::CloseWorker do
external_issue = ExternalIssue.new("foo", project)
closer = instance_double(Issues::CloseService, execute: true)
- expect(Issues::CloseService).to receive(:new).with(project: project, current_user: user).and_return(closer)
+ expect(Issues::CloseService).to receive(:new).with(container: project, current_user: user).and_return(closer)
expect(closer).to receive(:execute).with(external_issue, commit: commit)
worker.perform(project.id, external_issue.id, external_issue.class.to_s, opts)
diff --git a/spec/workers/merge_requests/close_issue_worker_spec.rb b/spec/workers/merge_requests/close_issue_worker_spec.rb
index 5e6bdc2a43e..72fb3be7470 100644
--- a/spec/workers/merge_requests/close_issue_worker_spec.rb
+++ b/spec/workers/merge_requests/close_issue_worker_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe MergeRequests::CloseIssueWorker do
let!(:merge_request) { create(:merge_request, source_project: project) }
it 'calls the close issue service' do
- expect_next_instance_of(Issues::CloseService, project: project, current_user: user) do |service|
+ expect_next_instance_of(Issues::CloseService, container: project, current_user: user) do |service|
expect(service).to receive(:execute).with(issue, commit: merge_request)
end