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-07-19 12:08:45 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-19 12:08:45 +0300
commit035cd5ee5e42fda4a896ed43147ebf455fa2f5ba (patch)
tree447d9362dd26fb42828d13777ffc821d7129dc0d /spec
parent7f12b2dc7406ceb8a9b1bbd730b38ad70fc88405 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/search_controller_spec.rb15
-rw-r--r--spec/features/merge_request/user_sees_versions_spec.rb36
-rw-r--r--spec/frontend/work_items/components/work_item_assignees_spec.js50
-rw-r--r--spec/initializers/00_connection_logger_spec.rb39
-rw-r--r--spec/lib/initializer_connections_spec.rb63
-rw-r--r--spec/models/ci/pipeline_spec.rb32
-rw-r--r--spec/models/namespace_spec.rb8
-rw-r--r--spec/models/project_spec.rb8
-rw-r--r--spec/requests/api/graphql/mutations/work_items/create_spec.rb14
-rw-r--r--spec/requests/api/graphql/mutations/work_items/update_spec.rb27
-rw-r--r--spec/services/work_items/parent_links/create_service_spec.rb22
-rw-r--r--spec/services/work_items/update_service_spec.rb2
-rw-r--r--spec/services/work_items/widgets/hierarchy_service/update_service_spec.rb14
13 files changed, 245 insertions, 85 deletions
diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb
index e4a7a2fc410..b4d4e01e972 100644
--- a/spec/controllers/search_controller_spec.rb
+++ b/spec/controllers/search_controller_spec.rb
@@ -408,10 +408,11 @@ RSpec.describe SearchController do
expect(payload[:metadata]['meta.search.filters.confidential']).to eq('true')
expect(payload[:metadata]['meta.search.filters.state']).to eq('true')
expect(payload[:metadata]['meta.search.project_ids']).to eq(%w(456 789))
- expect(payload[:metadata]['meta.search.search_level']).to eq('multi-project')
+ expect(payload[:metadata]['meta.search.type']).to eq('basic')
+ expect(payload[:metadata]['meta.search.level']).to eq('global')
end
- get :show, params: { scope: 'issues', search: 'hello world', group_id: '123', project_id: '456', project_ids: %w(456 789), search_level: 'multi-project', confidential: true, state: true, force_search_results: true }
+ get :show, params: { scope: 'issues', search: 'hello world', group_id: '123', project_id: '456', project_ids: %w(456 789), confidential: true, state: true, force_search_results: true }
end
it 'appends the default scope in meta.search.scope' do
@@ -423,6 +424,16 @@ RSpec.describe SearchController do
get :show, params: { search: 'hello world', group_id: '123', project_id: '456' }
end
+
+ it 'appends the search time based on the search' do
+ expect(controller).to receive(:append_info_to_payload).and_wrap_original do |method, payload|
+ method.call(payload)
+
+ expect(payload[:metadata][:global_search_duration_s]).to be_a_kind_of(Numeric)
+ end
+
+ get :show, params: { search: 'hello world', group_id: '123', project_id: '456' }
+ end
end
context 'abusive searches', :aggregate_failures do
diff --git a/spec/features/merge_request/user_sees_versions_spec.rb b/spec/features/merge_request/user_sees_versions_spec.rb
index 4465d7e29be..2c2a2dfd4a8 100644
--- a/spec/features/merge_request/user_sees_versions_spec.rb
+++ b/spec/features/merge_request/user_sees_versions_spec.rb
@@ -24,23 +24,21 @@ RSpec.describe 'Merge request > User sees versions', :js do
visit diffs_project_merge_request_path(project, merge_request, params)
end
- shared_examples 'allows commenting' do |file_id:, line_code:, comment:|
+ shared_examples 'allows commenting' do |file_name:, line_text:, comment:|
it do
- diff_file_selector = ".diff-file[id='#{file_id}']"
- line_code = "#{file_id}_#{line_code}"
+ page.within find_by_scrolling('.diff-file', text: file_name) do
+ line_code_element = page.find('.diff-grid-row', text: line_text)
- page.within find_by_scrolling(diff_file_selector) do
- line_code_element = first("[id='#{line_code}']")
# scrolling to element's bottom is required in order for .hover action to work
# otherwise, the element could be hidden underneath a sticky header
scroll_to_elements_bottom(line_code_element)
line_code_element.hover
- first("[id='#{line_code}'] [role='button']").click
+ page.find("[data-testid='left-comment-button']", visible: true).click
- page.within("form[data-line-code='#{line_code}']") do
- fill_in "note[note]", with: comment
- click_button('Add comment now')
- end
+ expect(page).to have_selector("form", count: 1)
+
+ fill_in("note[note]", with: comment)
+ click_button('Add comment now')
wait_for_requests
@@ -59,8 +57,8 @@ RSpec.describe 'Merge request > User sees versions', :js do
end
it_behaves_like 'allows commenting',
- file_id: '7445606fbf8f3683cd42bdc54b05d7a0bc2dfc44',
- line_code: '1_1',
+ file_name: '.gitmodules',
+ line_text: '[submodule "six"]',
comment: 'Typo, please fix.'
end
@@ -107,8 +105,8 @@ RSpec.describe 'Merge request > User sees versions', :js do
end
it_behaves_like 'allows commenting',
- file_id: '7445606fbf8f3683cd42bdc54b05d7a0bc2dfc44',
- line_code: '2_2',
+ file_name: '.gitmodules',
+ line_text: 'path = six',
comment: 'Typo, please fix.'
end
@@ -174,9 +172,9 @@ RSpec.describe 'Merge request > User sees versions', :js do
end
it_behaves_like 'allows commenting',
- file_id: '7445606fbf8f3683cd42bdc54b05d7a0bc2dfc44',
- line_code: '4_4',
- comment: 'Typo, please fix.'
+ file_name: '.gitmodules',
+ line_text: '[submodule "gitlab-shell"]',
+ comment: 'Typo, please fix.'
end
describe 'compare with same version' do
@@ -241,8 +239,8 @@ RSpec.describe 'Merge request > User sees versions', :js do
end
it_behaves_like 'allows commenting',
- file_id: '2f6fcd96b88b36ce98c38da085c795a27d92a3dd',
- line_code: '6_6',
+ file_name: 'files/ruby/popen.rb',
+ line_text: 'RuntimeError',
comment: 'Typo, please fix.'
end
end
diff --git a/spec/frontend/work_items/components/work_item_assignees_spec.js b/spec/frontend/work_items/components/work_item_assignees_spec.js
index 591102fb572..299949a4baa 100644
--- a/spec/frontend/work_items/components/work_item_assignees_spec.js
+++ b/spec/frontend/work_items/components/work_item_assignees_spec.js
@@ -4,13 +4,14 @@ import VueApollo from 'vue-apollo';
import createMockApollo from 'helpers/mock_apollo_helper';
import waitForPromises from 'helpers/wait_for_promises';
import { mountExtended } from 'helpers/vue_test_utils_helper';
+import { mockTracking } from 'helpers/tracking_helper';
import { stripTypenames } from 'helpers/graphql_helpers';
import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants';
import userSearchQuery from '~/graphql_shared/queries/users_search.query.graphql';
import currentUserQuery from '~/graphql_shared/queries/current_user.query.graphql';
import workItemQuery from '~/work_items/graphql/work_item.query.graphql';
import WorkItemAssignees from '~/work_items/components/work_item_assignees.vue';
-import { i18n } from '~/work_items/constants';
+import { i18n, TASK_TYPE_NAME, TRACKING_CATEGORY_SHOW } from '~/work_items/constants';
import { temporaryConfig, resolvers } from '~/work_items/graphql/provider';
import {
projectMembersResponseWithCurrentUser,
@@ -50,6 +51,7 @@ describe('WorkItemAssignees component', () => {
searchQueryHandler = successSearchQueryHandler,
currentUserQueryHandler = successCurrentUserQueryHandler,
allowsMultipleAssignees = true,
+ canUpdate = true,
} = {}) => {
const apolloProvider = createMockApollo(
[
@@ -78,6 +80,8 @@ describe('WorkItemAssignees component', () => {
assignees,
workItemId,
allowsMultipleAssignees,
+ workItemType: TASK_TYPE_NAME,
+ canUpdate,
},
attachTo: document.body,
apolloProvider,
@@ -125,6 +129,18 @@ describe('WorkItemAssignees component', () => {
expect(findTokenSelector().props('selectedTokens')).toEqual([mockAssignees[0]]);
});
+ it('passes `false` to `viewOnly` token selector prop if user can update assignees', () => {
+ createComponent();
+
+ expect(findTokenSelector().props('viewOnly')).toBe(false);
+ });
+
+ it('passes `true` to `viewOnly` token selector prop if user can not update assignees', () => {
+ createComponent({ canUpdate: false });
+
+ expect(findTokenSelector().props('viewOnly')).toBe(true);
+ });
+
describe('when searching for users', () => {
beforeEach(() => {
createComponent();
@@ -357,4 +373,36 @@ describe('WorkItemAssignees component', () => {
expect(findTokenSelector().props('containerClass')).toBe('gl-shadow-none!');
});
});
+
+ describe('tracking', () => {
+ let trackingSpy;
+
+ beforeEach(() => {
+ createComponent();
+ trackingSpy = mockTracking(undefined, wrapper.element, jest.spyOn);
+ });
+
+ afterEach(() => {
+ trackingSpy = null;
+ });
+
+ it('does not track updating assignees until token selector blur event', async () => {
+ findTokenSelector().vm.$emit('input', [mockAssignees[0]]);
+ await waitForPromises();
+
+ expect(trackingSpy).not.toHaveBeenCalled();
+ });
+
+ it('tracks editing the assignees on token selector blur', async () => {
+ findTokenSelector().vm.$emit('input', [mockAssignees[0]]);
+ findTokenSelector().vm.$emit('blur', new FocusEvent({ relatedTarget: null }));
+ await waitForPromises();
+
+ expect(trackingSpy).toHaveBeenCalledWith(TRACKING_CATEGORY_SHOW, 'updated_assignees', {
+ category: TRACKING_CATEGORY_SHOW,
+ label: 'item_assignees',
+ property: 'type_Task',
+ });
+ });
+ });
});
diff --git a/spec/initializers/00_connection_logger_spec.rb b/spec/initializers/00_connection_logger_spec.rb
deleted file mode 100644
index 8b288b463c4..00000000000
--- a/spec/initializers/00_connection_logger_spec.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe ActiveRecord::ConnectionAdapters::PostgreSQLAdapter do # rubocop:disable RSpec/FilePath
- before do
- allow(PG).to receive(:connect)
- end
-
- let(:conn_params) { PG::Connection.conndefaults_hash }
-
- context 'when warn_on_new_connection is enabled' do
- before do
- described_class.warn_on_new_connection = true
- end
-
- it 'warns on new connection' do
- expect(ActiveSupport::Deprecation)
- .to receive(:warn).with(/Database connection should not be called during initializers/, anything)
-
- expect(PG).to receive(:connect).with(conn_params)
-
- described_class.new_client(conn_params)
- end
- end
-
- context 'when warn_on_new_connection is disabled' do
- before do
- described_class.warn_on_new_connection = false
- end
-
- it 'does not warn on new connection' do
- expect(ActiveSupport::Deprecation).not_to receive(:warn)
- expect(PG).to receive(:connect).with(conn_params)
-
- described_class.new_client(conn_params)
- end
- end
-end
diff --git a/spec/lib/initializer_connections_spec.rb b/spec/lib/initializer_connections_spec.rb
new file mode 100644
index 00000000000..4ca283c4f22
--- /dev/null
+++ b/spec/lib/initializer_connections_spec.rb
@@ -0,0 +1,63 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe InitializerConnections do
+ describe '.with_disabled_database_connections', :reestablished_active_record_base do
+ def block_with_database_call
+ described_class.with_disabled_database_connections do
+ Project.first
+ end
+ end
+
+ def block_with_error
+ described_class.with_disabled_database_connections do
+ raise "oops, an error"
+ end
+ end
+
+ it 'prevents any database connection within the block' do
+ expect { block_with_database_call }.to raise_error(/Database connection should not be called during initializer/)
+ end
+
+ it 'does not prevent database connection if SKIP_RAISE_ON_INITIALIZE_CONNECTIONS is set' do
+ stub_env('SKIP_RAISE_ON_INITIALIZE_CONNECTIONS', '1')
+
+ expect { block_with_database_call }.not_to raise_error
+ end
+
+ it 'prevents any database connection if SKIP_RAISE_ON_INITIALIZE_CONNECTIONS is false' do
+ stub_env('SKIP_RAISE_ON_INITIALIZE_CONNECTIONS', 'false')
+
+ expect { block_with_database_call }.to raise_error(/Database connection should not be called during initializer/)
+ end
+
+ it 'restores original connection handler' do
+ # rubocop:disable Database/MultipleDatabases
+ original_handler = ActiveRecord::Base.connection_handler
+
+ expect { block_with_database_call }.to raise_error(/Database connection should not be called during initializer/)
+
+ expect(ActiveRecord::Base.connection_handler).to eq(original_handler)
+ # rubocop:enabled Database/MultipleDatabases
+ end
+
+ it 'restores original connection handler even there is an error' do
+ # rubocop:disable Database/MultipleDatabases
+ original_handler = ActiveRecord::Base.connection_handler
+
+ expect { block_with_error }.to raise_error(/an error/)
+
+ expect(ActiveRecord::Base.connection_handler).to eq(original_handler)
+ # rubocop:enabled Database/MultipleDatabases
+ end
+
+ it 'raises if any new connection_pools are established in the block' do
+ expect do
+ described_class.with_disabled_database_connections do
+ ApplicationRecord.connects_to database: { writing: :main, reading: :main }
+ end
+ end.to raise_error(/Unxpected connection_pools/)
+ end
+ end
+end
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index 5a50ce0911f..081fa6cbbae 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -3953,7 +3953,21 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
context 'when pipeline status is running' do
let(:pipeline) { create(:ci_pipeline, :running) }
- it { is_expected.to be_falsey }
+ context 'with mr_show_reports_immediately flag enabled' do
+ before do
+ stub_feature_flags(mr_show_reports_immediately: project)
+ end
+
+ it { expect(subject).to be_truthy }
+ end
+
+ context 'with mr_show_reports_immediately flag disabled' do
+ before do
+ stub_feature_flags(mr_show_reports_immediately: false)
+ end
+
+ it { expect(subject).to be_falsey }
+ end
end
context 'when pipeline status is success' do
@@ -4027,7 +4041,21 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
context 'when pipeline status is running' do
let(:pipeline) { create(:ci_pipeline, :running) }
- it { expect(subject).to be_falsey }
+ context 'with mr_show_reports_immediately flag enabled' do
+ before do
+ stub_feature_flags(mr_show_reports_immediately: project)
+ end
+
+ it { expect(subject).to be_truthy }
+ end
+
+ context 'with mr_show_reports_immediately flag disabled' do
+ before do
+ stub_feature_flags(mr_show_reports_immediately: false)
+ end
+
+ it { expect(subject).to be_falsey }
+ end
end
context 'when pipeline status is success' do
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb
index de478edf96a..664cdb27290 100644
--- a/spec/models/namespace_spec.rb
+++ b/spec/models/namespace_spec.rb
@@ -1884,6 +1884,14 @@ RSpec.describe Namespace do
end
end
+ describe '#emails_enabled?' do
+ it "is the opposite of emails_disabled" do
+ group = create(:group, emails_disabled: false)
+
+ expect(group.emails_enabled?).to be_truthy
+ end
+ end
+
describe '#pages_virtual_domain' do
let(:project) { create(:project, namespace: namespace) }
let(:virtual_domain) { namespace.pages_virtual_domain }
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 74a4a023a20..2171ee752fd 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -3595,6 +3595,14 @@ RSpec.describe Project, factory_default: :keep do
end
end
+ describe '#emails_enabled?' do
+ let(:project) { build(:project, emails_disabled: false) }
+
+ it "is the opposite of emails_disabled" do
+ expect(project.emails_enabled?).to be_truthy
+ end
+ end
+
describe '#lfs_enabled?' do
let(:namespace) { create(:namespace) }
let(:project) { build(:project, namespace: namespace) }
diff --git a/spec/requests/api/graphql/mutations/work_items/create_spec.rb b/spec/requests/api/graphql/mutations/work_items/create_spec.rb
index 3496ab38ee8..911568bc39f 100644
--- a/spec/requests/api/graphql/mutations/work_items/create_spec.rb
+++ b/spec/requests/api/graphql/mutations/work_items/create_spec.rb
@@ -136,6 +136,20 @@ RSpec.describe 'Create a work item' do
end
end
end
+
+ context 'when unsupported widget input is sent' do
+ let(:input) do
+ {
+ 'title' => 'new title',
+ 'description' => 'new description',
+ 'workItemTypeId' => WorkItems::Type.default_by_type(:test_case).to_global_id.to_s,
+ 'hierarchyWidget' => {}
+ }
+ end
+
+ it_behaves_like 'a mutation that returns top-level errors',
+ errors: ['Following widget keys are not supported by Test Case type: [:hierarchy_widget]']
+ end
end
context 'when the work_items feature flag is disabled' do
diff --git a/spec/requests/api/graphql/mutations/work_items/update_spec.rb b/spec/requests/api/graphql/mutations/work_items/update_spec.rb
index b5f0eb7fbf6..77f7b9bacef 100644
--- a/spec/requests/api/graphql/mutations/work_items/update_spec.rb
+++ b/spec/requests/api/graphql/mutations/work_items/update_spec.rb
@@ -71,6 +71,20 @@ RSpec.describe 'Update a work item' do
end
end
+ context 'when unsupported widget input is sent' do
+ let_it_be(:test_case) { create(:work_item_type, :default, :test_case, name: 'some_test_case_name') }
+ let_it_be(:work_item) { create(:work_item, work_item_type: test_case, project: project) }
+
+ let(:input) do
+ {
+ 'hierarchyWidget' => {}
+ }
+ end
+
+ it_behaves_like 'a mutation that returns top-level errors',
+ errors: ["Following widget keys are not supported by some_test_case_name type: [:hierarchy_widget]"]
+ end
+
it_behaves_like 'has spam protection' do
let(:mutation_class) { ::Mutations::WorkItems::Update }
end
@@ -295,6 +309,19 @@ RSpec.describe 'Update a work item' do
end
end
+ context 'when there is a mix of existing and non existing work items' do
+ let(:children_ids) { [valid_child1.to_global_id.to_s, "gid://gitlab/WorkItem/#{non_existing_record_id}"] }
+
+ it 'returns a top level error and does not add valid work item' do
+ expect do
+ post_graphql_mutation(mutation, current_user: current_user)
+ work_item.reload
+ end.not_to change(work_item.work_item_children, :count)
+
+ expect(graphql_errors.first['message']).to include('No object found for `childrenIds')
+ end
+ end
+
context 'when child work item type is valid' do
let(:children_ids) { [valid_child1.to_global_id.to_s, valid_child2.to_global_id.to_s] }
diff --git a/spec/services/work_items/parent_links/create_service_spec.rb b/spec/services/work_items/parent_links/create_service_spec.rb
index a2f695900ae..85b0ee040cd 100644
--- a/spec/services/work_items/parent_links/create_service_spec.rb
+++ b/spec/services/work_items/parent_links/create_service_spec.rb
@@ -49,19 +49,19 @@ RSpec.describe WorkItems::ParentLinks::CreateService do
end
context 'when work item not found' do
- let(:params) { { issuable_references: [invalid_task.id] } }
+ let(:params) { { issuable_references: [invalid_task] } }
it_behaves_like 'returns not found error'
end
context 'when user has no permission to link work items' do
- let(:params) { { issuable_references: [guest_task.id] } }
+ let(:params) { { issuable_references: [guest_task] } }
it_behaves_like 'returns not found error'
end
context 'child and parent are the same work item' do
- let(:params) { { issuable_references: [work_item.id] } }
+ let(:params) { { issuable_references: [work_item] } }
it 'no relationship is created' do
expect { subject }.not_to change(parent_link_class, :count)
@@ -69,7 +69,7 @@ RSpec.describe WorkItems::ParentLinks::CreateService do
end
context 'when there are tasks to relate' do
- let(:params) { { issuable_references: [task1.id, task2.id] } }
+ let(:params) { { issuable_references: [task1, task2] } }
it 'creates relationships', :aggregate_failures do
expect { subject }.to change(parent_link_class, :count).by(2)
@@ -85,7 +85,7 @@ RSpec.describe WorkItems::ParentLinks::CreateService do
end
context 'when task is already assigned' do
- let(:params) { { issuable_references: [task.id, task2.id] } }
+ let(:params) { { issuable_references: [task, task2] } }
it 'creates links only for non related tasks' do
expect { subject }.to change(parent_link_class, :count).by(1)
@@ -97,7 +97,7 @@ RSpec.describe WorkItems::ParentLinks::CreateService do
context 'when there are invalid children' do
let_it_be(:issue) { create(:work_item, project: project) }
- let(:params) { { issuable_references: [task1.id, issue.id, other_project_task.id] } }
+ let(:params) { { issuable_references: [task1, issue, other_project_task] } }
it 'creates links only for valid children' do
expect { subject }.to change { parent_link_class.count }.by(1)
@@ -124,7 +124,7 @@ RSpec.describe WorkItems::ParentLinks::CreateService do
end
context 'when max depth is reached' do
- let(:params) { { issuable_references: [task2.id] } }
+ let(:params) { { issuable_references: [task2] } }
before do
stub_const("#{parent_link_class}::MAX_CHILDREN", 1)
@@ -138,17 +138,11 @@ RSpec.describe WorkItems::ParentLinks::CreateService do
end
context 'when params include invalid ids' do
- let(:params) { { issuable_references: [task1.id, invalid_task.id] } }
+ let(:params) { { issuable_references: [task1, invalid_task] } }
it 'creates links only for valid IDs' do
expect { subject }.to change(parent_link_class, :count).by(1)
end
-
- it 'returns error for invalid ID' do
- message = "Task with ID: #{invalid_task.id} could not be found."
-
- expect(subject).to eq(service_error(message, http_status: 422))
- end
end
context 'when user is a guest' do
diff --git a/spec/services/work_items/update_service_spec.rb b/spec/services/work_items/update_service_spec.rb
index 3423b92e35c..b17c9ffb4fb 100644
--- a/spec/services/work_items/update_service_spec.rb
+++ b/spec/services/work_items/update_service_spec.rb
@@ -148,7 +148,7 @@ RSpec.describe WorkItems::UpdateService do
let(:opts) { { title: 'changed' } }
let_it_be(:child_work_item) { create(:work_item, :task, project: project) }
- let(:widget_params) { { hierarchy_widget: { children_ids: [child_work_item.id] } } }
+ let(:widget_params) { { hierarchy_widget: { children: [child_work_item] } } }
it 'updates the children of the work item' do
expect do
diff --git a/spec/services/work_items/widgets/hierarchy_service/update_service_spec.rb b/spec/services/work_items/widgets/hierarchy_service/update_service_spec.rb
index c48e17431bf..4f6ff1b8676 100644
--- a/spec/services/work_items/widgets/hierarchy_service/update_service_spec.rb
+++ b/spec/services/work_items/widgets/hierarchy_service/update_service_spec.rb
@@ -21,8 +21,8 @@ RSpec.describe WorkItems::Widgets::HierarchyService::UpdateService do
describe '#update' do
subject { described_class.new(widget: widget, current_user: user).before_update_in_transaction(params: params) }
- context 'when parent and children_ids params are present' do
- let(:params) { { parent: parent_work_item, children_ids: [child_work_item.id] } }
+ context 'when parent and children params are present' do
+ let(:params) { { parent: parent_work_item, children: [child_work_item] } }
it_behaves_like 'raises a WidgetError' do
let(:message) { 'A Work Item can be a parent or a child, but not both.' }
@@ -35,7 +35,7 @@ RSpec.describe WorkItems::Widgets::HierarchyService::UpdateService do
let_it_be(:child_work_item4) { create(:work_item, :task, project: project) }
context 'when work_items_hierarchy feature flag is disabled' do
- let(:params) { { children_ids: [child_work_item4.id] }}
+ let(:params) { { children: [child_work_item4] }}
before do
stub_feature_flags(work_items_hierarchy: false)
@@ -47,7 +47,7 @@ RSpec.describe WorkItems::Widgets::HierarchyService::UpdateService do
end
context 'when user has insufficient permissions to link work items' do
- let(:params) { { children_ids: [child_work_item4.id] }}
+ let(:params) { { children: [child_work_item4] }}
it_behaves_like 'raises a WidgetError' do
let(:message) { not_found_error }
@@ -60,7 +60,7 @@ RSpec.describe WorkItems::Widgets::HierarchyService::UpdateService do
end
context 'with valid params' do
- let(:params) { { children_ids: [child_work_item2.id, child_work_item3.id] }}
+ let(:params) { { children: [child_work_item2, child_work_item3] }}
it 'correctly sets work item parent' do
subject
@@ -71,7 +71,7 @@ RSpec.describe WorkItems::Widgets::HierarchyService::UpdateService do
end
context 'when child is already assigned' do
- let(:params) { { children_ids: [child_work_item.id] }}
+ let(:params) { { children: [child_work_item] }}
it_behaves_like 'raises a WidgetError' do
let(:message) { 'Task(s) already assigned' }
@@ -81,7 +81,7 @@ RSpec.describe WorkItems::Widgets::HierarchyService::UpdateService do
context 'when child type is invalid' do
let_it_be(:child_issue) { create(:work_item, project: project) }
- let(:params) { { children_ids: [child_issue.id] }}
+ let(:params) { { children: [child_issue] }}
it_behaves_like 'raises a WidgetError' do
let(:message) do