summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-12-08 21:09:17 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-08 21:09:17 +0000
commit1690313142e39075d231271bfdbc9ad95957106a (patch)
tree971c63ccab0947c43fc777ea45f19495d855062b /spec
parent54943f1e68bd4e1951bf3d6c438acab8d783fc31 (diff)
downloadgitlab-ce-1690313142e39075d231271bfdbc9ad95957106a.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/features/boards/boards_spec.rb20
-rw-r--r--spec/features/dashboard/todos/todos_filtering_spec.rb20
-rw-r--r--spec/features/dashboard/todos/todos_spec.rb101
-rw-r--r--spec/frontend/pages/dashboard/todos/index/todos_spec.js117
-rw-r--r--spec/graphql/types/ci/pipeline_schedule_type_spec.rb1
-rw-r--r--spec/helpers/markup_helper_spec.rb51
-rw-r--r--spec/helpers/todos_helper_spec.rb56
-rw-r--r--spec/lib/gitlab/shell_spec.rb42
-rw-r--r--spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb111
-rw-r--r--spec/lib/gitlab/usage_data_spec.rb30
-rw-r--r--spec/models/merge_request_spec.rb12
-rw-r--r--spec/requests/admin/applications_controller_spec.rb3
-rw-r--r--spec/requests/admin/background_migrations_controller_spec.rb2
-rw-r--r--spec/requests/admin/batched_jobs_controller_spec.rb2
-rw-r--r--spec/requests/admin/broadcast_messages_controller_spec.rb2
-rw-r--r--spec/requests/admin/clusters/integrations_controller_spec.rb2
-rw-r--r--spec/requests/admin/hook_logs_controller_spec.rb2
-rw-r--r--spec/requests/admin/impersonation_tokens_controller_spec.rb3
-rw-r--r--spec/requests/admin/integrations_controller_spec.rb2
-rw-r--r--spec/requests/admin/version_check_controller_spec.rb2
-rw-r--r--spec/requests/api/graphql/ci/pipeline_schedules_spec.rb23
-rw-r--r--spec/requests/concerns/planning_hierarchy_spec.rb2
-rw-r--r--spec/requests/dashboard/projects_controller_spec.rb2
-rw-r--r--spec/requests/groups/autocomplete_sources_spec.rb2
-rw-r--r--spec/requests/groups/clusters/integrations_controller_spec.rb2
-rw-r--r--spec/requests/groups/crm/contacts_controller_spec.rb2
-rw-r--r--spec/requests/groups/crm/organizations_controller_spec.rb2
-rw-r--r--spec/requests/groups/deploy_tokens_controller_spec.rb2
-rw-r--r--spec/requests/groups/email_campaigns_controller_spec.rb2
-rw-r--r--spec/requests/groups/harbor/artifacts_controller_spec.rb2
-rw-r--r--spec/requests/groups/harbor/repositories_controller_spec.rb2
-rw-r--r--spec/requests/groups/harbor/tags_controller_spec.rb2
-rw-r--r--spec/requests/groups/milestones_controller_spec.rb2
-rw-r--r--spec/requests/groups/observability_controller_spec.rb2
-rw-r--r--spec/requests/groups/registry/repositories_controller_spec.rb2
-rw-r--r--spec/requests/groups/settings/access_tokens_controller_spec.rb2
-rw-r--r--spec/requests/groups/settings/applications_controller_spec.rb2
-rw-r--r--spec/requests/import/github_groups_controller_spec.rb2
-rw-r--r--spec/requests/import/gitlab_groups_controller_spec.rb2
-rw-r--r--spec/requests/import/gitlab_projects_controller_spec.rb2
-rw-r--r--spec/requests/import/url_controller_spec.rb2
-rw-r--r--spec/requests/jira_connect/oauth_application_ids_controller_spec.rb2
-rw-r--r--spec/requests/jira_connect/oauth_callbacks_controller_spec.rb2
-rw-r--r--spec/requests/jira_connect/users_controller_spec.rb2
-rw-r--r--spec/requests/mailgun/webhooks_controller_spec.rb2
-rw-r--r--spec/requests/oauth/applications_controller_spec.rb2
-rw-r--r--spec/requests/oauth/authorizations_controller_spec.rb2
-rw-r--r--spec/requests/oauth/tokens_controller_spec.rb2
-rw-r--r--spec/requests/profiles/notifications_controller_spec.rb2
-rw-r--r--spec/services/chat_names/find_user_service_spec.rb28
-rw-r--r--spec/services/groups/destroy_service_spec.rb20
-rw-r--r--spec/services/projects/after_rename_service_spec.rb29
-rw-r--r--spec/support/helpers/test_env.rb6
-rw-r--r--spec/workers/repository_check/single_repository_worker_spec.rb10
54 files changed, 279 insertions, 474 deletions
diff --git a/spec/features/boards/boards_spec.rb b/spec/features/boards/boards_spec.rb
index 072cfacbe3b..3e2e391d060 100644
--- a/spec/features/boards/boards_spec.rb
+++ b/spec/features/boards/boards_spec.rb
@@ -89,7 +89,7 @@ RSpec.describe 'Project issue boards', :js, feature_category: :team_planning do
let_it_be(:issue10, reload: true) { create(:labeled_issue, project: project, title: 'issue +', description: 'A+ great issue', labels: [a_plus]) }
before do
- visit_project_board(project, board)
+ visit_project_board_path_without_query_limit(project, board)
end
it 'shows description tooltip on list title', :quarantine do
@@ -103,7 +103,7 @@ RSpec.describe 'Project issue boards', :js, feature_category: :team_planning do
wait_for_board_cards(3, 2)
end
- it 'shows confidential issues with icon' do
+ it 'shows confidential issues with icon', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/383970' do
page.within(find('.board:nth-child(2)')) do
expect(page).to have_selector('.confidential-icon', count: 1)
end
@@ -179,7 +179,7 @@ RSpec.describe 'Project issue boards', :js, feature_category: :team_planning do
end
end
- context 'closed' do
+ context 'closed', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/383970' do
it 'shows list of closed issues' do
wait_for_board_cards(4, 1)
wait_for_requests
@@ -256,7 +256,7 @@ RSpec.describe 'Project issue boards', :js, feature_category: :team_planning do
expect(page).to have_selector(selector, text: development.title, count: 1)
end
- it 'issue moves between lists and does not show the "Development" label since the card is in the "Development" list label' do
+ it 'issue moves between lists and does not show the "Development" label since the card is in the "Development" list label', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/383970' do
drag(list_from_index: 1, from_index: 1, list_to_index: 2)
wait_for_board_cards(2, 7)
@@ -267,7 +267,7 @@ RSpec.describe 'Project issue boards', :js, feature_category: :team_planning do
expect(find('.board:nth-child(3)').all('.board-card').last).not_to have_content(development.title)
end
- it 'issue moves between lists and does not show the "Planning" label since the card is in the "Planning" list label' do
+ it 'issue moves between lists and does not show the "Planning" label since the card is in the "Planning" list label', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/383970' do
drag(list_from_index: 2, list_to_index: 1)
wait_for_board_cards(2, 9)
@@ -278,7 +278,7 @@ RSpec.describe 'Project issue boards', :js, feature_category: :team_planning do
expect(find('.board:nth-child(2)').all('.board-card').first).not_to have_content(planning.title)
end
- it 'issue moves from closed' do
+ it 'issue moves from closed', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/383970' do
drag(list_from_index: 2, list_to_index: 3)
wait_for_board_cards(2, 8)
@@ -295,7 +295,7 @@ RSpec.describe 'Project issue boards', :js, feature_category: :team_planning do
end
end
- context 'list header' do
+ context 'list header', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/383970' do
let(:total_planning_issues) { "8" }
it 'shows issue count on the list' do
@@ -319,7 +319,7 @@ RSpec.describe 'Project issue boards', :js, feature_category: :team_planning do
wait_for_empty_boards((3..4))
end
- it 'filters by assignee' do
+ it 'filters by assignee', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/383970' do
set_filter("assignee", user.username)
click_on user.username
filter_submit.click
@@ -341,7 +341,7 @@ RSpec.describe 'Project issue boards', :js, feature_category: :team_planning do
wait_for_board_cards(4, 0)
end
- it 'filters by label' do
+ it 'filters by label', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/383970' do
set_filter("label", testing.title)
click_on testing.title
filter_submit.click
@@ -400,7 +400,7 @@ RSpec.describe 'Project issue boards', :js, feature_category: :team_planning do
wait_for_board_cards(2, 8)
end
- it 'infinite scrolls list with label filter' do
+ it 'infinite scrolls list with label filter', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/383970' do
create_list(:labeled_issue, 30, project: project, labels: [planning, testing])
set_filter("label", testing.title)
diff --git a/spec/features/dashboard/todos/todos_filtering_spec.rb b/spec/features/dashboard/todos/todos_filtering_spec.rb
index d7ad97e1696..4af3a93b916 100644
--- a/spec/features/dashboard/todos/todos_filtering_spec.rb
+++ b/spec/features/dashboard/todos/todos_filtering_spec.rb
@@ -58,9 +58,9 @@ RSpec.describe 'Dashboard > User filters todos', :js, feature_category: :team_pl
wait_for_requests
- expect(page).to have_content "issue #{issue1.to_reference} \"issue\" at #{group1.name} / project_1"
- expect(page).to have_content "merge request #{merge_request.to_reference}"
- expect(page).not_to have_content "issue #{issue2.to_reference} \"issue\" at #{group2.name} / project_3"
+ expect(page).to have_content "#{group1.name} / project_1 #{issue1.to_reference} · issue"
+ expect(page).to have_content merge_request.to_reference.to_s
+ expect(page).not_to have_content "#{group2.name} / project_3 #{issue2.to_reference} · issue"
end
context 'Author filter' do
@@ -74,8 +74,8 @@ RSpec.describe 'Dashboard > User filters todos', :js, feature_category: :team_pl
wait_for_requests
- expect(find('.todos-list')).to have_content 'merge request'
- expect(find('.todos-list')).not_to have_content 'issue'
+ expect(find('.todos-list')).to have_content '!'
+ expect(find('.todos-list')).not_to have_content '#'
end
it 'shows only authors of existing todos' do
@@ -174,11 +174,11 @@ RSpec.describe 'Dashboard > User filters todos', :js, feature_category: :team_pl
def expect_to_see_action(action_name)
action_names = {
- assigned: ' assigned you ',
- review_requested: ' requested a review of ',
- mentioned: ' mentioned ',
- marked: ' added a todo for ',
- build_failed: ' pipeline failed in '
+ assigned: ' assigned you',
+ review_requested: ' requested a review',
+ mentioned: ' mentioned',
+ marked: ' added a to-do item',
+ build_failed: ' pipeline failed'
}
action_name_text = action_names.delete(action_name)
diff --git a/spec/features/dashboard/todos/todos_spec.rb b/spec/features/dashboard/todos/todos_spec.rb
index 4808a6abc32..4ec7859a292 100644
--- a/spec/features/dashboard/todos/todos_spec.rb
+++ b/spec/features/dashboard/todos/todos_spec.rb
@@ -49,29 +49,8 @@ RSpec.describe 'Dashboard Todos', feature_category: :team_planning do
visit dashboard_todos_path
end
- it 'renders the mr link with the extra attributes' do
- link = page.find_link(referenced_mr.to_reference)
-
- expect(link).not_to be_nil
- expect(link['data-iid']).to eq(referenced_mr.iid.to_s)
- expect(link['data-project-path']).to eq(referenced_mr.project.full_path)
- expect(link['title']).to eq(referenced_mr.title)
- expect(link['data-reference-type']).to eq('merge_request')
- end
- end
-
- context 'when todo references an issue of type task' do
- let(:task) { create(:issue, :task, project: project) }
- let!(:task_todo) { create(:todo, :mentioned, user: user, project: project, target: task, author: author) }
-
- before do
- sign_in(user)
-
- visit dashboard_todos_path
- end
-
- it 'displays the correct issue type name' do
- expect(page).to have_content('mentioned you on task')
+ it 'renders the mr reference' do
+ expect(page).to have_content(referenced_mr.to_reference)
end
end
@@ -100,10 +79,6 @@ RSpec.describe 'Dashboard Todos', feature_category: :team_planning do
visit dashboard_todos_path
end
- it 'displays the correct issue type name' do
- expect(page).to have_content('mentioned you on issue')
- end
-
it 'has todo present' do
expect(page).to have_selector('.todos-list .todo', count: 1)
end
@@ -117,7 +92,7 @@ RSpec.describe 'Dashboard Todos', feature_category: :team_planning do
shared_examples 'deleting the todo' do
before do
within first('.todo') do
- click_link 'Done'
+ find('[data-testid="check-icon"]').click
end
end
@@ -143,9 +118,9 @@ RSpec.describe 'Dashboard Todos', feature_category: :team_planning do
shared_examples 'deleting and restoring the todo' do
before do
within first('.todo') do
- click_link 'Done'
+ find('[data-testid="check-icon"]').click
wait_for_requests
- click_link 'Undo'
+ find('[data-testid="redo-icon"]').click
end
end
@@ -192,7 +167,8 @@ RSpec.describe 'Dashboard Todos', feature_category: :team_planning do
it 'shows issue assigned to yourself message' do
page.within('.js-todos-all') do
- expect(page).to have_content("You assigned issue #{issue.to_reference} \"Fix bug\" at #{project.namespace.owner_name} / #{project.name} to yourself")
+ expect(page).to have_content("#{project.namespace.owner_name} / #{project.name} #{issue.to_reference} · Fix bug")
+ expect(page).to have_content("You assigned to yourself.")
end
end
end
@@ -203,10 +179,10 @@ RSpec.describe 'Dashboard Todos', feature_category: :team_planning do
visit dashboard_todos_path
end
- it 'shows you added a todo message' do
+ it 'shows you added a to-do item message' do
page.within('.js-todos-all') do
- expect(page).to have_content("You added a todo for issue #{issue.to_reference} \"Fix bug\" at #{project.namespace.owner_name} / #{project.name}")
- expect(page).not_to have_content('to yourself')
+ expect(page).to have_content("#{project.namespace.owner_name} / #{project.name} #{issue.to_reference} · Fix bug")
+ expect(page).to have_content("You added a to-do item.")
end
end
end
@@ -219,8 +195,8 @@ RSpec.describe 'Dashboard Todos', feature_category: :team_planning do
it 'shows you mentioned yourself message' do
page.within('.js-todos-all') do
- expect(page).to have_content("You mentioned yourself on issue #{issue.to_reference} \"Fix bug\" at #{project.namespace.owner_name} / #{project.name}")
- expect(page).not_to have_content('to yourself')
+ expect(page).to have_content("#{project.namespace.owner_name} / #{project.name} #{issue.to_reference} · Fix bug")
+ expect(page).to have_content("You mentioned yourself.")
end
end
end
@@ -233,8 +209,8 @@ RSpec.describe 'Dashboard Todos', feature_category: :team_planning do
it 'shows you directly addressed yourself message being displayed as mentioned yourself' do
page.within('.js-todos-all') do
- expect(page).to have_content("You mentioned yourself on issue #{issue.to_reference} \"Fix bug\" at #{project.namespace.owner_name} / #{project.name}")
- expect(page).not_to have_content('to yourself')
+ expect(page).to have_content("#{project.namespace.owner_name} / #{project.name} #{issue.to_reference} · Fix bug")
+ expect(page).to have_content("You mentioned yourself.")
end
end
end
@@ -249,8 +225,8 @@ RSpec.describe 'Dashboard Todos', feature_category: :team_planning do
it 'shows you set yourself as an approver message' do
page.within('.js-todos-all') do
- expect(page).to have_content("You set yourself as an approver for merge request #{merge_request.to_reference} \"Fixes issue\" at #{project.namespace.owner_name} / #{project.name}")
- expect(page).not_to have_content('to yourself')
+ expect(page).to have_content("#{project.namespace.owner_name} / #{project.name} #{merge_request.to_reference} · Fixes issue")
+ expect(page).to have_content("You set yourself as an approver.")
end
end
end
@@ -265,7 +241,28 @@ RSpec.describe 'Dashboard Todos', feature_category: :team_planning do
it 'shows you set yourself as an reviewer message' do
page.within('.js-todos-all') do
- expect(page).to have_content("You requested a review of merge request #{merge_request.to_reference} \"Fixes issue\" at #{project.namespace.owner_name} / #{project.name} from yourself")
+ expect(page).to have_content("#{project.namespace.owner_name} / #{project.name} #{merge_request.to_reference} · Fixes issue")
+ expect(page).to have_content("You requested a review from yourself.")
+ end
+ end
+ end
+ end
+
+ context 'User has automatically created todos' do
+ before do
+ sign_in(user)
+ end
+
+ context 'unmergeable todo' do
+ before do
+ create(:todo, :unmergeable, user: user, project: project, target: issue, author: user)
+ visit dashboard_todos_path
+ end
+
+ it 'shows unmergeable message' do
+ page.within('.js-todos-all') do
+ expect(page).to have_content("#{project.namespace.owner_name} / #{project.name} #{issue.to_reference} · Fix bug")
+ expect(page).to have_content("Could not merge.")
end
end
end
@@ -285,7 +282,7 @@ RSpec.describe 'Dashboard Todos', feature_category: :team_planning do
describe 'restoring the todo' do
before do
within first('.todo') do
- click_link 'Add a to do'
+ find('[data-testid="todo-add-icon"]').click
end
end
@@ -391,7 +388,7 @@ RSpec.describe 'Dashboard Todos', feature_category: :team_planning do
context 'User has deleted a todo' do
before do
within first('.todo') do
- click_link 'Done'
+ find('[data-testid="check-icon"]').click
end
end
@@ -420,13 +417,7 @@ RSpec.describe 'Dashboard Todos', feature_category: :team_planning do
end
it 'shows the todo' do
- expect(page).to have_content 'The pipeline failed in merge request'
- end
-
- it 'links to the pipelines for the merge request' do
- href = pipelines_project_merge_request_path(project, todo.target)
-
- expect(page).to have_link "merge request #{todo.target.to_reference}", href: href
+ expect(page).to have_content 'The pipeline failed.'
end
end
@@ -453,15 +444,5 @@ RSpec.describe 'Dashboard Todos', feature_category: :team_planning do
it 'has todo present' do
expect(page).to have_selector('.todos-list .todo', count: 1)
end
-
- it 'has a link that will take me to the design page' do
- click_link "design #{target.to_reference}"
-
- expectation = Gitlab::Routing.url_helpers.designs_project_issue_path(
- target.project, target.issue, target.filename
- )
-
- expect(page).to have_current_path(expectation, ignore_query: true)
- end
end
end
diff --git a/spec/frontend/pages/dashboard/todos/index/todos_spec.js b/spec/frontend/pages/dashboard/todos/index/todos_spec.js
index 03aed7454e3..825aef27327 100644
--- a/spec/frontend/pages/dashboard/todos/index/todos_spec.js
+++ b/spec/frontend/pages/dashboard/todos/index/todos_spec.js
@@ -4,7 +4,6 @@ import waitForPromises from 'helpers/wait_for_promises';
import '~/lib/utils/common_utils';
import axios from '~/lib/utils/axios_utils';
import { addDelimiter } from '~/lib/utils/text_utility';
-import { visitUrl } from '~/lib/utils/url_utility';
import Todos from '~/pages/dashboard/todos/index/todos';
jest.mock('~/lib/utils/url_utility', () => ({
@@ -15,12 +14,10 @@ const TEST_COUNT_BIG = 2000;
const TEST_DONE_COUNT_BIG = 7300;
describe('Todos', () => {
- let todoItem;
let mock;
beforeEach(() => {
loadHTMLFixture('todos/todos.html');
- todoItem = document.querySelector('.todos-list .todo');
mock = new MockAdapter(axios);
return new Todos();
@@ -34,95 +31,47 @@ describe('Todos', () => {
mock.restore();
});
- describe('goToTodoUrl', () => {
- it('opens the todo url', () => {
- const todoLink = todoItem.dataset.url;
+ describe('on done todo click', () => {
+ let onToggleSpy;
- let expectedUrl = null;
- visitUrl.mockImplementation((url) => {
- expectedUrl = url;
- });
+ beforeEach(() => {
+ const el = document.querySelector('.js-done-todo');
+ const path = el.dataset.href;
- todoItem.click();
+ // Arrange
+ mock
+ .onDelete(path)
+ .replyOnce(200, { count: TEST_COUNT_BIG, done_count: TEST_DONE_COUNT_BIG });
+ onToggleSpy = jest.fn();
+ document.addEventListener('todo:toggle', onToggleSpy);
- expect(expectedUrl).toEqual(todoLink);
- });
-
- describe('meta click', () => {
- let windowOpenSpy;
- let metakeyEvent;
-
- beforeEach(() => {
- metakeyEvent = new MouseEvent('click', { ctrlKey: true });
- windowOpenSpy = jest.spyOn(window, 'open').mockImplementation(() => {});
- });
-
- it('opens the todo url in another tab', () => {
- const todoLink = todoItem.dataset.url;
-
- document.querySelectorAll('.todos-list .todo').forEach((el) => {
- el.dispatchEvent(metakeyEvent);
- });
-
- expect(visitUrl).not.toHaveBeenCalled();
- expect(windowOpenSpy).toHaveBeenCalledWith(todoLink, '_blank');
- });
-
- it('run native funcionality when avatar is clicked', () => {
- document.querySelectorAll('.todos-list a').forEach((el) => {
- el.addEventListener('click', (e) => e.preventDefault());
- });
- document.querySelectorAll('.todos-list img').forEach((el) => {
- el.dispatchEvent(metakeyEvent);
- });
+ // Act
+ el.click();
- expect(visitUrl).not.toHaveBeenCalled();
- expect(windowOpenSpy).not.toHaveBeenCalled();
- });
+ // Wait for axios and HTML to udpate
+ return waitForPromises();
});
- describe('on done todo click', () => {
- let onToggleSpy;
-
- beforeEach(() => {
- const el = document.querySelector('.js-done-todo');
- const path = el.dataset.href;
-
- // Arrange
- mock
- .onDelete(path)
- .replyOnce(200, { count: TEST_COUNT_BIG, done_count: TEST_DONE_COUNT_BIG });
- onToggleSpy = jest.fn();
- document.addEventListener('todo:toggle', onToggleSpy);
-
- // Act
- el.click();
-
- // Wait for axios and HTML to udpate
- return waitForPromises();
- });
-
- it('dispatches todo:toggle', () => {
- expect(onToggleSpy).toHaveBeenCalledWith(
- expect.objectContaining({
- detail: {
- count: TEST_COUNT_BIG,
- },
- }),
- );
- });
+ it('dispatches todo:toggle', () => {
+ expect(onToggleSpy).toHaveBeenCalledWith(
+ expect.objectContaining({
+ detail: {
+ count: TEST_COUNT_BIG,
+ },
+ }),
+ );
+ });
- it('updates pending text', () => {
- expect(document.querySelector('.js-todos-pending .js-todos-badge').innerHTML).toEqual(
- addDelimiter(TEST_COUNT_BIG),
- );
- });
+ it('updates pending text', () => {
+ expect(document.querySelector('.js-todos-pending .js-todos-badge').innerHTML).toEqual(
+ addDelimiter(TEST_COUNT_BIG),
+ );
+ });
- it('updates done text', () => {
- expect(document.querySelector('.js-todos-done .js-todos-badge').innerHTML).toEqual(
- addDelimiter(TEST_DONE_COUNT_BIG),
- );
- });
+ it('updates done text', () => {
+ expect(document.querySelector('.js-todos-done .js-todos-badge').innerHTML).toEqual(
+ addDelimiter(TEST_DONE_COUNT_BIG),
+ );
});
});
});
diff --git a/spec/graphql/types/ci/pipeline_schedule_type_spec.rb b/spec/graphql/types/ci/pipeline_schedule_type_spec.rb
index bf1413ef657..e14ff453be0 100644
--- a/spec/graphql/types/ci/pipeline_schedule_type_spec.rb
+++ b/spec/graphql/types/ci/pipeline_schedule_type_spec.rb
@@ -23,6 +23,7 @@ RSpec.describe Types::Ci::PipelineScheduleType do
cron
cronTimezone
userPermissions
+ editPath
]
expect(described_class).to have_graphql_fields(*expected_fields)
diff --git a/spec/helpers/markup_helper_spec.rb b/spec/helpers/markup_helper_spec.rb
index 0b3d400041c..d1c86abf6e9 100644
--- a/spec/helpers/markup_helper_spec.rb
+++ b/spec/helpers/markup_helper_spec.rb
@@ -445,11 +445,25 @@ RSpec.describe MarkupHelper do
shared_examples_for 'common markdown examples' do
let(:project_base) { build(:project, :repository) }
+ it 'displays inline code' do
+ object = create_object('Text with `inline code`')
+ expected = 'Text with <code>inline code</code>'
+
+ expect(first_line_in_markdown(object, attribute, 100, is_todo: true, project: project)).to match(expected)
+ end
+
+ it 'truncates the text with multiple paragraphs' do
+ object = create_object("Paragraph 1\n\nParagraph 2")
+ expected = 'Paragraph 1...'
+
+ expect(first_line_in_markdown(object, attribute, 100, is_todo: true, project: project)).to match(expected)
+ end
+
it 'displays the first line of a code block' do
object = create_object("```\nCode block\nwith two lines\n```")
expected = %r{<pre.+><code><span class="line">Code block\.\.\.</span>\n</code></pre>}
- expect(first_line_in_markdown(object, attribute, 100, project: project)).to match(expected)
+ expect(first_line_in_markdown(object, attribute, 100, is_todo: true, project: project)).to match(expected)
end
it 'truncates a single long line of text' do
@@ -457,7 +471,7 @@ RSpec.describe MarkupHelper do
object = create_object(text * 4)
expected = (text * 2).sub(/.{3}/, '...')
- expect(first_line_in_markdown(object, attribute, 150, project: project)).to match(expected)
+ expect(first_line_in_markdown(object, attribute, 150, is_todo: true, project: project)).to match(expected)
end
it 'preserves code color scheme' do
@@ -466,28 +480,15 @@ RSpec.describe MarkupHelper do
"<code><span class=\"line\"><span class=\"k\">def</span> <span class=\"nf\">test</span>...</span>\n" \
"</code></pre>\n"
- expect(first_line_in_markdown(object, attribute, 150, project: project)).to eq(expected)
+ expect(first_line_in_markdown(object, attribute, 150, is_todo: true, project: project)).to eq(expected)
end
- context 'when images are allowed' do
- it 'preserves data-src for lazy images' do
- object = create_object("![ImageTest](/uploads/test.png)")
- image_url = "data-src=\".*/uploads/test.png\""
- text = first_line_in_markdown(object, attribute, 150, project: project, allow_images: true)
+ it 'removes any images' do
+ object = create_object("![ImageTest](/uploads/test.png)")
+ text = first_line_in_markdown(object, attribute, 150, is_todo: true, project: project)
- expect(text).to match(image_url)
- expect(text).to match('<a')
- end
- end
-
- context 'when images are not allowed' do
- it 'removes any images' do
- object = create_object("![ImageTest](/uploads/test.png)")
- text = first_line_in_markdown(object, attribute, 150, project: project)
-
- expect(text).not_to match('<img')
- expect(text).not_to match('<a')
- end
+ expect(text).not_to match('<img')
+ expect(text).not_to match('<a')
end
context 'labels formatting' do
@@ -497,7 +498,7 @@ RSpec.describe MarkupHelper do
create(:label, title: 'label_1', project: project)
object = create_object(label_title, project: project)
- first_line_in_markdown(object, attribute, 150, project: project)
+ first_line_in_markdown(object, attribute, 150, is_todo: true, project: project)
end
it 'preserves style attribute for a label that can be accessed by current_user' do
@@ -518,10 +519,10 @@ RSpec.describe MarkupHelper do
end
it 'keeps whitelisted tags' do
- html = '<a><i></i></a> <strong>strong</strong><em>em</em><b>b</b>'
+ html = '<i></i> <strong>strong</strong><em>em</em><b>b</b>'
object = create_object(html)
- result = first_line_in_markdown(object, attribute, 100, project: project)
+ result = first_line_in_markdown(object, attribute, 100, is_todo: true, project: project)
expect(result).to include(html)
end
@@ -530,7 +531,7 @@ RSpec.describe MarkupHelper do
object = create_object("hello \n\n [Test](README.md)")
expect do
- first_line_in_markdown(object, attribute, nil, project: project)
+ first_line_in_markdown(object, attribute, 100, is_todo: true, project: project)
end.not_to change { Gitlab::GitalyClient.get_request_count }
end
end
diff --git a/spec/helpers/todos_helper_spec.rb b/spec/helpers/todos_helper_spec.rb
index 5e8e62451a9..a3679caa1d8 100644
--- a/spec/helpers/todos_helper_spec.rb
+++ b/spec/helpers/todos_helper_spec.rb
@@ -50,16 +50,14 @@ RSpec.describe TodosHelper do
end
end
- describe '#todo_target_link' do
+ describe '#todo_target_name' do
context 'when given a design' do
let(:todo) { design_todo }
- it 'produces a good link' do
- path = helper.todo_target_path(todo)
- link = helper.todo_target_link(todo)
- expected = "<a href=\"#{path}\">design #{design.to_reference}</a>"
+ it 'references the filename of the design' do
+ name = helper.todo_target_name(todo)
- expect(link).to eq(expected)
+ expect(name).to eq(design.to_reference.to_s)
end
end
end
@@ -94,7 +92,7 @@ RSpec.describe TodosHelper do
it 'returns the title' do
title = helper.todo_target_title(todo)
- expect(title).to eq("\"Issue 1\"")
+ expect(title).to eq("Issue 1")
end
end
end
@@ -177,31 +175,31 @@ RSpec.describe TodosHelper do
end
end
- describe '#todo_target_type_name' do
- subject { helper.todo_target_type_name(todo) }
+ describe '#todo_target_aria_label' do
+ subject { helper.todo_target_aria_label(todo) }
context 'when given a design todo' do
let(:todo) { design_todo }
- it { is_expected.to eq('design') }
+ it { is_expected.to eq("Design ##{todo.target.iid}[#{todo.target.title}]") }
end
context 'when given an alert todo' do
let(:todo) { alert_todo }
- it { is_expected.to eq('alert') }
+ it { is_expected.to eq("Alert ^alert##{todo.target.iid}") }
end
context 'when given a task todo' do
let(:todo) { task_todo }
- it { is_expected.to eq('task') }
+ it { is_expected.to eq("Task ##{todo.target.iid}") }
end
context 'when given an issue todo' do
let(:todo) { issue_todo }
- it { is_expected.to eq('issue') }
+ it { is_expected.to eq("Issue ##{todo.target.iid}") }
end
context 'when given a merge request todo' do
@@ -210,7 +208,7 @@ RSpec.describe TodosHelper do
create(:todo, target: merge_request)
end
- it { is_expected.to eq('merge request') }
+ it { is_expected.to eq("Merge Request !#{todo.target.iid}") }
end
end
@@ -249,7 +247,7 @@ RSpec.describe TodosHelper do
todo.target.update!(state: 'closed')
end
- it_behaves_like 'a rendered state pill', css: '.gl-bg-red-500', state: 'closed'
+ it_behaves_like 'a rendered state pill', css: '.badge-danger', state: 'closed'
end
context 'merged MR' do
@@ -257,7 +255,7 @@ RSpec.describe TodosHelper do
todo.target.update!(state: 'merged')
end
- it_behaves_like 'a rendered state pill', css: '.gl-bg-blue-500', state: 'merged'
+ it_behaves_like 'a rendered state pill', css: '.badge-info', state: 'merged'
end
end
@@ -271,7 +269,7 @@ RSpec.describe TodosHelper do
todo.target.update!(state: 'closed')
end
- it_behaves_like 'a rendered state pill', css: '.gl-bg-blue-500', state: 'closed'
+ it_behaves_like 'a rendered state pill', css: '.badge-info', state: 'closed'
end
end
@@ -285,7 +283,7 @@ RSpec.describe TodosHelper do
todo.target.resolve!
end
- it_behaves_like 'a rendered state pill', css: '.gl-bg-blue-500', state: 'resolved'
+ it_behaves_like 'a rendered state pill', css: '.badge-info', state: 'resolved'
end
end
end
@@ -349,18 +347,18 @@ RSpec.describe TodosHelper do
where(:action, :self_added?, :expected_action_name) do
Todo::ASSIGNED | false | s_('Todos|assigned you')
Todo::ASSIGNED | true | s_('Todos|assigned')
- Todo::REVIEW_REQUESTED | true | s_('Todos|requested a review of')
- Todo::MENTIONED | true | format(s_("Todos|mentioned %{who} on"), who: s_('Todos|yourself'))
- Todo::MENTIONED | false | format(s_("Todos|mentioned %{who} on"), who: _('you'))
- Todo::DIRECTLY_ADDRESSED | true | format(s_("Todos|mentioned %{who} on"), who: s_('Todos|yourself'))
- Todo::DIRECTLY_ADDRESSED | false | format(s_("Todos|mentioned %{who} on"), who: _('you'))
- Todo::BUILD_FAILED | true | s_('Todos|The pipeline failed in')
- Todo::MARKED | true | s_('Todos|added a todo for')
- Todo::APPROVAL_REQUIRED | true | format(s_("Todos|set %{who} as an approver for"), who: s_('Todos|yourself'))
- Todo::APPROVAL_REQUIRED | false | format(s_("Todos|set %{who} as an approver for"), who: _('you'))
+ Todo::REVIEW_REQUESTED | true | s_('Todos|requested a review')
+ Todo::MENTIONED | true | format(s_("Todos|mentioned %{who}"), who: s_('Todos|yourself'))
+ Todo::MENTIONED | false | format(s_("Todos|mentioned %{who}"), who: _('you'))
+ Todo::DIRECTLY_ADDRESSED | true | format(s_("Todos|mentioned %{who}"), who: s_('Todos|yourself'))
+ Todo::DIRECTLY_ADDRESSED | false | format(s_("Todos|mentioned %{who}"), who: _('you'))
+ Todo::BUILD_FAILED | true | s_('Todos|The pipeline failed')
+ Todo::MARKED | true | s_('Todos|added a to-do item')
+ Todo::APPROVAL_REQUIRED | true | format(s_("Todos|set %{who} as an approver"), who: s_('Todos|yourself'))
+ Todo::APPROVAL_REQUIRED | false | format(s_("Todos|set %{who} as an approver"), who: _('you'))
Todo::UNMERGEABLE | true | s_('Todos|Could not merge')
- Todo::MERGE_TRAIN_REMOVED | true | s_("Todos|Removed from Merge Train:")
- Todo::MEMBER_ACCESS_REQUESTED | true | s_("Todos|has requested access to")
+ Todo::MERGE_TRAIN_REMOVED | true | s_("Todos|Removed from Merge Train")
+ Todo::MEMBER_ACCESS_REQUESTED | true | s_("Todos|has requested access")
end
with_them do
diff --git a/spec/lib/gitlab/shell_spec.rb b/spec/lib/gitlab/shell_spec.rb
index 785429aa3b0..049b8d4ed86 100644
--- a/spec/lib/gitlab/shell_spec.rb
+++ b/spec/lib/gitlab/shell_spec.rb
@@ -88,18 +88,11 @@ RSpec.describe Gitlab::Shell do
let(:disk_path) { "#{project.disk_path}.git" }
it 'returns true when the command succeeds' do
- expect(TestEnv.storage_dir_exists?(project.repository_storage, disk_path)).to be(true)
+ expect(project.repository.raw).to exist
expect(gitlab_shell.remove_repository(project.repository_storage, project.disk_path)).to be(true)
- expect(TestEnv.storage_dir_exists?(project.repository_storage, disk_path)).to be(false)
- end
-
- it 'keeps the namespace directory' do
- gitlab_shell.remove_repository(project.repository_storage, project.disk_path)
-
- expect(TestEnv.storage_dir_exists?(project.repository_storage, disk_path)).to be(false)
- expect(TestEnv.storage_dir_exists?(project.repository_storage, project.disk_path.gsub(project.name, ''))).to be(true)
+ expect(project.repository.raw).not_to exist
end
end
@@ -107,21 +100,22 @@ RSpec.describe Gitlab::Shell do
let!(:project2) { create(:project, :repository) }
it 'returns true when the command succeeds' do
- old_path = project2.disk_path
+ old_repo = project2.repository.raw
new_path = "project/new_path"
+ new_repo = Gitlab::Git::Repository.new(project2.repository_storage, "#{new_path}.git", nil, nil)
- expect(TestEnv.storage_dir_exists?(project2.repository_storage, "#{old_path}.git")).to be(true)
- expect(TestEnv.storage_dir_exists?(project2.repository_storage, "#{new_path}.git")).to be(false)
+ expect(old_repo).to exist
+ expect(new_repo).not_to exist
- expect(gitlab_shell.mv_repository(project2.repository_storage, old_path, new_path)).to be_truthy
+ expect(gitlab_shell.mv_repository(project2.repository_storage, project2.disk_path, new_path)).to be_truthy
- expect(TestEnv.storage_dir_exists?(project2.repository_storage, "#{old_path}.git")).to be(false)
- expect(TestEnv.storage_dir_exists?(project2.repository_storage, "#{new_path}.git")).to be(true)
+ expect(old_repo).not_to exist
+ expect(new_repo).to exist
end
it 'returns false when the command fails' do
expect(gitlab_shell.mv_repository(project2.repository_storage, project2.disk_path, '')).to be_falsy
- expect(TestEnv.storage_dir_exists?(project2.repository_storage, "#{project2.disk_path}.git")).to be(true)
+ expect(project2.repository.raw).to exist
end
end
end
@@ -133,9 +127,11 @@ RSpec.describe Gitlab::Shell do
describe '#add_namespace' do
it 'creates a namespace' do
- Gitlab::GitalyClient::NamespaceService.allow { subject.add_namespace(storage, "mepmep") }
+ Gitlab::GitalyClient::NamespaceService.allow do
+ subject.add_namespace(storage, "mepmep")
- expect(TestEnv.storage_dir_exists?(storage, "mepmep")).to be(true)
+ expect(Gitlab::GitalyClient::NamespaceService.new(storage).exists?("mepmep")).to be(true)
+ end
end
end
@@ -160,9 +156,9 @@ RSpec.describe Gitlab::Shell do
Gitlab::GitalyClient::NamespaceService.allow do
subject.add_namespace(storage, "mepmep")
subject.rm_namespace(storage, "mepmep")
- end
- expect(TestEnv.storage_dir_exists?(storage, "mepmep")).to be(false)
+ expect(Gitlab::GitalyClient::NamespaceService.new(storage).exists?("mepmep")).to be(false)
+ end
end
end
@@ -171,10 +167,10 @@ RSpec.describe Gitlab::Shell do
Gitlab::GitalyClient::NamespaceService.allow do
subject.add_namespace(storage, "mepmep")
subject.mv_namespace(storage, "mepmep", "2mep")
- end
- expect(TestEnv.storage_dir_exists?(storage, "mepmep")).to be(false)
- expect(TestEnv.storage_dir_exists?(storage, "2mep")).to be(true)
+ expect(Gitlab::GitalyClient::NamespaceService.new(storage).exists?("mepmep")).to be(false)
+ expect(Gitlab::GitalyClient::NamespaceService.new(storage).exists?("2mep")).to be(true)
+ end
end
end
end
diff --git a/spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb b/spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
index e84a67c3fba..1d980c48c72 100644
--- a/spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
+++ b/spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
@@ -23,70 +23,6 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
described_class.clear_memoization(:known_events)
end
- context 'migration to instrumentation classes data collection' do
- let_it_be(:instrumented_events) do
- instrumentation_classes = %w[AggregatedMetric RedisHLLMetric]
- ::Gitlab::Usage::MetricDefinition.all.map do |definition|
- next unless definition.available?
- next unless instrumentation_classes.include?(definition.attributes[:instrumentation_class])
-
- definition.attributes.dig(:options, :events)&.sort
- end.compact.to_set
- end
-
- def not_instrumented_events(category)
- described_class
- .events_for_category(category)
- .sort
- .reject do |event|
- instrumented_events.include?([event])
- end
- end
-
- def not_instrumented_aggregate(category)
- events = described_class.events_for_category(category).sort
-
- return unless described_class::CATEGORIES_FOR_TOTALS.include?(category)
- return unless described_class.send(:eligible_for_totals?, events)
- return if instrumented_events.include?(events)
-
- events
- end
-
- describe 'Gitlab::UsageDataCounters::HLLRedisCounter::CATEGORIES_COLLECTED_FROM_METRICS_DEFINITIONS' do
- it 'includes only fully migrated categories' do
- wrong_skipped_events = described_class::CATEGORIES_COLLECTED_FROM_METRICS_DEFINITIONS.map do |category|
- next if not_instrumented_events(category).empty? && not_instrumented_aggregate(category).nil?
-
- [category, [not_instrumented_events(category), not_instrumented_aggregate(category)].compact]
- end.compact.to_h
-
- expect(wrong_skipped_events).to be_empty
- end
-
- context 'with not instrumented category' do
- let(:instrumented_events) { [] }
-
- it 'can detect not migrated category' do
- wrong_skipped_events = described_class::CATEGORIES_COLLECTED_FROM_METRICS_DEFINITIONS.map do |category|
- next if not_instrumented_events(category).empty? && not_instrumented_aggregate(category).nil?
-
- [category, [not_instrumented_events(category), not_instrumented_aggregate(category)].compact]
- end.compact.to_h
-
- expect(wrong_skipped_events).not_to be_empty
- end
- end
- end
-
- describe '.unique_events_data' do
- it 'does not include instrumented categories' do
- expect(described_class.unique_events_data.keys)
- .not_to include(*described_class.categories_collected_from_metrics_definitions)
- end
- end
- end
-
describe '.categories' do
it 'gets CE unique category names' do
expect(described_class.categories).to include(
@@ -560,53 +496,6 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
end
end
- describe 'unique_events_data' do
- let(:known_events) do
- [
- { name: 'event1_slot', redis_slot: "slot", category: 'category1', aggregation: "weekly" },
- { name: 'event2_slot', redis_slot: "slot", category: 'category1', aggregation: "weekly" },
- { name: 'event3', category: 'category2', aggregation: "weekly" },
- { name: 'event4', category: 'category2', aggregation: "weekly" }
- ].map(&:with_indifferent_access)
- end
-
- before do
- allow(described_class).to receive(:known_events).and_return(known_events)
- allow(described_class).to receive(:categories).and_return(%w(category1 category2))
-
- stub_const('Gitlab::UsageDataCounters::HLLRedisCounter::CATEGORIES_FOR_TOTALS', %w(category1 category2))
-
- described_class.track_event('event1_slot', values: entity1, time: 2.days.ago)
- described_class.track_event('event2_slot', values: entity2, time: 2.days.ago)
- described_class.track_event('event2_slot', values: entity3, time: 2.weeks.ago)
-
- # events in different slots
- described_class.track_event('event3', values: entity2, time: 2.days.ago)
- described_class.track_event('event4', values: entity2, time: 2.days.ago)
- end
-
- it 'returns the number of unique events for all known events' do
- results = {
- "category1" => {
- "event1_slot_weekly" => 1,
- "event1_slot_monthly" => 1,
- "event2_slot_weekly" => 1,
- "event2_slot_monthly" => 2,
- "category1_total_unique_counts_weekly" => 2,
- "category1_total_unique_counts_monthly" => 3
- },
- "category2" => {
- "event3_weekly" => 1,
- "event3_monthly" => 1,
- "event4_weekly" => 1,
- "event4_monthly" => 1
- }
- }
-
- expect(subject.unique_events_data).to eq(results)
- end
- end
-
describe '.calculate_events_union' do
let(:time_range) { { start_date: 7.days.ago, end_date: DateTime.current } }
let(:known_events) do
diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb
index 00d4ce6d8fe..214331e15e8 100644
--- a/spec/lib/gitlab/usage_data_spec.rb
+++ b/spec/lib/gitlab/usage_data_spec.rb
@@ -1109,36 +1109,6 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
end
end
- describe 'redis_hll_counters' do
- subject { described_class.redis_hll_counters }
-
- let(:migrated_categories) do
- ::Gitlab::UsageDataCounters::HLLRedisCounter.categories_collected_from_metrics_definitions
- end
-
- let(:categories) { ::Gitlab::UsageDataCounters::HLLRedisCounter.categories - migrated_categories }
- let(:ignored_metrics) { ["i_package_composer_deploy_token_weekly"] }
-
- it 'has all known_events' do
- expect(subject).to have_key(:redis_hll_counters)
-
- expect(subject[:redis_hll_counters].keys).to match_array(categories)
-
- categories.each do |category|
- keys = ::Gitlab::UsageDataCounters::HLLRedisCounter.events_for_category(category)
-
- metrics = keys.map { |key| "#{key}_weekly" } + keys.map { |key| "#{key}_monthly" }
- metrics -= ignored_metrics
-
- if ::Gitlab::UsageDataCounters::HLLRedisCounter::CATEGORIES_FOR_TOTALS.include?(category)
- metrics.append("#{category}_total_unique_counts_weekly", "#{category}_total_unique_counts_monthly")
- end
-
- expect(subject[:redis_hll_counters][category].keys).to match_array(metrics)
- end
- end
- end
-
describe '.service_desk_counts' do
subject { described_class.send(:service_desk_counts) }
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index ccc77c7259f..05586cbfc64 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -4244,6 +4244,18 @@ RSpec.describe MergeRequest, factory_default: :keep do
transition!
end
+
+ context 'when transaction is not committed' do
+ it_behaves_like 'transition not triggering mergeRequestMergeStatusUpdated GraphQL subscription' do
+ def transition!
+ MergeRequest.transaction do
+ super
+
+ raise ActiveRecord::Rollback
+ end
+ end
+ end
+ end
end
shared_examples 'for an invalid state transition' do
diff --git a/spec/requests/admin/applications_controller_spec.rb b/spec/requests/admin/applications_controller_spec.rb
index 03553757080..c83137ebbce 100644
--- a/spec/requests/admin/applications_controller_spec.rb
+++ b/spec/requests/admin/applications_controller_spec.rb
@@ -2,7 +2,8 @@
require 'spec_helper'
-RSpec.describe Admin::ApplicationsController, :enable_admin_mode do
+RSpec.describe Admin::ApplicationsController, :enable_admin_mode,
+feature_category: :authentication_and_authorization do
let_it_be(:admin) { create(:admin) }
let_it_be(:application) { create(:oauth_application, owner_id: nil, owner_type: nil) }
let_it_be(:show_path) { admin_application_path(application) }
diff --git a/spec/requests/admin/background_migrations_controller_spec.rb b/spec/requests/admin/background_migrations_controller_spec.rb
index fe2a2470511..db3e2fa0df6 100644
--- a/spec/requests/admin/background_migrations_controller_spec.rb
+++ b/spec/requests/admin/background_migrations_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Admin::BackgroundMigrationsController, :enable_admin_mode do
+RSpec.describe Admin::BackgroundMigrationsController, :enable_admin_mode, feature_category: :database do
let(:admin) { create(:admin) }
before do
diff --git a/spec/requests/admin/batched_jobs_controller_spec.rb b/spec/requests/admin/batched_jobs_controller_spec.rb
index fb51b3bce88..8060b19b8b3 100644
--- a/spec/requests/admin/batched_jobs_controller_spec.rb
+++ b/spec/requests/admin/batched_jobs_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Admin::BatchedJobsController, :enable_admin_mode do
+RSpec.describe Admin::BatchedJobsController, :enable_admin_mode, feature_category: :database do
let(:admin) { create(:admin) }
before do
diff --git a/spec/requests/admin/broadcast_messages_controller_spec.rb b/spec/requests/admin/broadcast_messages_controller_spec.rb
index eb29092845c..69b84d6d795 100644
--- a/spec/requests/admin/broadcast_messages_controller_spec.rb
+++ b/spec/requests/admin/broadcast_messages_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Admin::BroadcastMessagesController, :enable_admin_mode do
+RSpec.describe Admin::BroadcastMessagesController, :enable_admin_mode, feature_category: :onboarding do
let(:broadcast_message) { build(:broadcast_message) }
let(:broadcast_message_params) { broadcast_message.as_json(root: true, only: [:message, :starts_at, :ends_at]) }
diff --git a/spec/requests/admin/clusters/integrations_controller_spec.rb b/spec/requests/admin/clusters/integrations_controller_spec.rb
index ee1c1d5aad4..d5e3f03627a 100644
--- a/spec/requests/admin/clusters/integrations_controller_spec.rb
+++ b/spec/requests/admin/clusters/integrations_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Admin::Clusters::IntegrationsController, :enable_admin_mode do
+RSpec.describe Admin::Clusters::IntegrationsController, :enable_admin_mode, feature_category: :integrations do
include AccessMatchersForController
shared_examples 'a secure endpoint' do
diff --git a/spec/requests/admin/hook_logs_controller_spec.rb b/spec/requests/admin/hook_logs_controller_spec.rb
index f8d3381c052..fa9f317dbba 100644
--- a/spec/requests/admin/hook_logs_controller_spec.rb
+++ b/spec/requests/admin/hook_logs_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Admin::HookLogsController, :enable_admin_mode do
+RSpec.describe Admin::HookLogsController, :enable_admin_mode, feature_category: :integrations do
let_it_be(:user) { create(:admin) }
let_it_be_with_refind(:web_hook) { create(:system_hook) }
let_it_be_with_refind(:web_hook_log) { create(:web_hook_log, web_hook: web_hook) }
diff --git a/spec/requests/admin/impersonation_tokens_controller_spec.rb b/spec/requests/admin/impersonation_tokens_controller_spec.rb
index ee0e12ad0c0..15212db0e77 100644
--- a/spec/requests/admin/impersonation_tokens_controller_spec.rb
+++ b/spec/requests/admin/impersonation_tokens_controller_spec.rb
@@ -2,7 +2,8 @@
require 'spec_helper'
-RSpec.describe Admin::ImpersonationTokensController, :enable_admin_mode do
+RSpec.describe Admin::ImpersonationTokensController, :enable_admin_mode,
+feature_category: :authentication_and_authorization do
let(:admin) { create(:admin) }
let!(:user) { create(:user) }
diff --git a/spec/requests/admin/integrations_controller_spec.rb b/spec/requests/admin/integrations_controller_spec.rb
index 128aada0975..efd0e3d91ee 100644
--- a/spec/requests/admin/integrations_controller_spec.rb
+++ b/spec/requests/admin/integrations_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Admin::IntegrationsController, :enable_admin_mode do
+RSpec.describe Admin::IntegrationsController, :enable_admin_mode, feature_category: :integrations do
let_it_be(:admin) { create(:admin) }
before do
diff --git a/spec/requests/admin/version_check_controller_spec.rb b/spec/requests/admin/version_check_controller_spec.rb
index 7e2f33d5bc5..47221bf37e5 100644
--- a/spec/requests/admin/version_check_controller_spec.rb
+++ b/spec/requests/admin/version_check_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Admin::VersionCheckController, :enable_admin_mode do
+RSpec.describe Admin::VersionCheckController, :enable_admin_mode, feature_category: :not_owned do
let(:admin) { create(:admin) }
before do
diff --git a/spec/requests/api/graphql/ci/pipeline_schedules_spec.rb b/spec/requests/api/graphql/ci/pipeline_schedules_spec.rb
index 8b8ba09a95c..1d152297fd2 100644
--- a/spec/requests/api/graphql/ci/pipeline_schedules_spec.rb
+++ b/spec/requests/api/graphql/ci/pipeline_schedules_spec.rb
@@ -5,8 +5,8 @@ require 'spec_helper'
RSpec.describe 'Query.project.pipelineSchedules' do
include GraphqlHelpers
- let_it_be(:project) { create(:project, :repository, :public) }
let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project, :repository, :public, creator: user, namespace: user.namespace) }
let_it_be(:pipeline_schedule) { create(:ci_pipeline_schedule, project: project, owner: user) }
let(:pipeline_schedule_graphql_data) { graphql_data_at(:project, :pipeline_schedules, :nodes, 0) }
@@ -29,6 +29,7 @@ RSpec.describe 'Query.project.pipelineSchedules' do
forTag
cron
cronTimezone
+ editPath
}
QUERY
end
@@ -61,6 +62,26 @@ RSpec.describe 'Query.project.pipelineSchedules' do
expect(pipeline_schedule_graphql_data['refPath']).to eq("/#{project.full_path}/-/commits/#{ref_for_display}")
expect(pipeline_schedule_graphql_data['forTag']).to be(false)
end
+
+ it 'returns the edit_path for a pipeline schedule' do
+ edit_path = pipeline_schedule_graphql_data['editPath']
+
+ expect(edit_path).to eq("/#{project.full_path}/-/pipeline_schedules/#{pipeline_schedule.id}/edit")
+ end
+ end
+
+ describe 'permissions' do
+ let_it_be(:another_user) { create(:user) }
+
+ before do
+ post_graphql(query, current_user: another_user)
+ end
+
+ it 'does not return the edit_path for a pipeline schedule for a user that does not have permissions' do
+ edit_path = pipeline_schedule_graphql_data['editPath']
+
+ expect(edit_path).to be nil
+ end
end
it 'avoids N+1 queries' do
diff --git a/spec/requests/concerns/planning_hierarchy_spec.rb b/spec/requests/concerns/planning_hierarchy_spec.rb
index ece9270b3a1..89232916936 100644
--- a/spec/requests/concerns/planning_hierarchy_spec.rb
+++ b/spec/requests/concerns/planning_hierarchy_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe PlanningHierarchy, type: :request do
+RSpec.describe PlanningHierarchy, type: :request, feature_category: :projects do
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
diff --git a/spec/requests/dashboard/projects_controller_spec.rb b/spec/requests/dashboard/projects_controller_spec.rb
index 4cd3b6c4f9e..752799196c9 100644
--- a/spec/requests/dashboard/projects_controller_spec.rb
+++ b/spec/requests/dashboard/projects_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Dashboard::ProjectsController do
+RSpec.describe Dashboard::ProjectsController, feature_category: :projects do
context 'token authentication' do
it_behaves_like 'authenticates sessionless user for the request spec', 'index atom', public_resource: false do
let(:url) { dashboard_projects_url(:atom) }
diff --git a/spec/requests/groups/autocomplete_sources_spec.rb b/spec/requests/groups/autocomplete_sources_spec.rb
index d053e0fe773..e44fb9f6c37 100644
--- a/spec/requests/groups/autocomplete_sources_spec.rb
+++ b/spec/requests/groups/autocomplete_sources_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe 'groups autocomplete' do
+RSpec.describe 'groups autocomplete', feature_category: :subgroups do
let_it_be(:user) { create(:user) }
let_it_be_with_reload(:group) { create(:group, :private) }
diff --git a/spec/requests/groups/clusters/integrations_controller_spec.rb b/spec/requests/groups/clusters/integrations_controller_spec.rb
index 29e37e2e48c..0b9148e917b 100644
--- a/spec/requests/groups/clusters/integrations_controller_spec.rb
+++ b/spec/requests/groups/clusters/integrations_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Groups::Clusters::IntegrationsController do
+RSpec.describe Groups::Clusters::IntegrationsController, features: :integrations do
include AccessMatchersForController
shared_examples 'a secure endpoint' do
diff --git a/spec/requests/groups/crm/contacts_controller_spec.rb b/spec/requests/groups/crm/contacts_controller_spec.rb
index 70086ddbbba..4916ce60108 100644
--- a/spec/requests/groups/crm/contacts_controller_spec.rb
+++ b/spec/requests/groups/crm/contacts_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Groups::Crm::ContactsController do
+RSpec.describe Groups::Crm::ContactsController, feature_category: :team_planning do
let_it_be(:user) { create(:user) }
shared_examples 'response with 404 status' do
diff --git a/spec/requests/groups/crm/organizations_controller_spec.rb b/spec/requests/groups/crm/organizations_controller_spec.rb
index e841dd80b67..3e7e9a8e878 100644
--- a/spec/requests/groups/crm/organizations_controller_spec.rb
+++ b/spec/requests/groups/crm/organizations_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Groups::Crm::OrganizationsController do
+RSpec.describe Groups::Crm::OrganizationsController, feature_category: :team_planning do
let_it_be(:user) { create(:user) }
shared_examples 'response with 404 status' do
diff --git a/spec/requests/groups/deploy_tokens_controller_spec.rb b/spec/requests/groups/deploy_tokens_controller_spec.rb
index b3dce9b9cf1..05fd8d9691c 100644
--- a/spec/requests/groups/deploy_tokens_controller_spec.rb
+++ b/spec/requests/groups/deploy_tokens_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Groups::DeployTokensController do
+RSpec.describe Groups::DeployTokensController, feature_category: :continuous_delivery do
let_it_be(:group) { create(:group) }
let_it_be(:user) { create(:user) }
let_it_be(:deploy_token) { create(:deploy_token, :group, groups: [group]) }
diff --git a/spec/requests/groups/email_campaigns_controller_spec.rb b/spec/requests/groups/email_campaigns_controller_spec.rb
index 4d630ef6710..7db5c084793 100644
--- a/spec/requests/groups/email_campaigns_controller_spec.rb
+++ b/spec/requests/groups/email_campaigns_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Groups::EmailCampaignsController do
+RSpec.describe Groups::EmailCampaignsController, feature_category: :navigation do
using RSpec::Parameterized::TableSyntax
describe 'GET #index', :snowplow do
diff --git a/spec/requests/groups/harbor/artifacts_controller_spec.rb b/spec/requests/groups/harbor/artifacts_controller_spec.rb
index ea9529119a6..7ec792d081d 100644
--- a/spec/requests/groups/harbor/artifacts_controller_spec.rb
+++ b/spec/requests/groups/harbor/artifacts_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Groups::Harbor::ArtifactsController do
+RSpec.describe Groups::Harbor::ArtifactsController, feature_category: :build_artifacts do
it_behaves_like 'a harbor artifacts controller', anonymous_status_code: '404' do
let_it_be(:container) { create(:group) }
let_it_be(:harbor_integration) { create(:harbor_integration, group: container, project: nil) }
diff --git a/spec/requests/groups/harbor/repositories_controller_spec.rb b/spec/requests/groups/harbor/repositories_controller_spec.rb
index b4022561f54..f397e9192ea 100644
--- a/spec/requests/groups/harbor/repositories_controller_spec.rb
+++ b/spec/requests/groups/harbor/repositories_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Groups::Harbor::RepositoriesController do
+RSpec.describe Groups::Harbor::RepositoriesController, feature_category: :source_code_management do
it_behaves_like 'a harbor repositories controller', anonymous_status_code: '404' do
let_it_be(:container, reload: true) { create(:group) }
let_it_be(:harbor_integration) { create(:harbor_integration, group: container, project: nil) }
diff --git a/spec/requests/groups/harbor/tags_controller_spec.rb b/spec/requests/groups/harbor/tags_controller_spec.rb
index 257d4366837..15da1cb1c4b 100644
--- a/spec/requests/groups/harbor/tags_controller_spec.rb
+++ b/spec/requests/groups/harbor/tags_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Groups::Harbor::TagsController do
+RSpec.describe Groups::Harbor::TagsController, feature_category: :source_code_management do
it_behaves_like 'a harbor tags controller', anonymous_status_code: '404' do
let_it_be(:container) { create(:group) }
let_it_be(:harbor_integration) { create(:harbor_integration, group: container, project: nil) }
diff --git a/spec/requests/groups/milestones_controller_spec.rb b/spec/requests/groups/milestones_controller_spec.rb
index e6418c7694d..54a25333c02 100644
--- a/spec/requests/groups/milestones_controller_spec.rb
+++ b/spec/requests/groups/milestones_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Groups::MilestonesController do
+RSpec.describe Groups::MilestonesController, feature_category: :team_planning do
context 'N+1 DB queries' do
let_it_be(:user) { create(:user) }
let_it_be(:public_group) { create(:group, :public) }
diff --git a/spec/requests/groups/observability_controller_spec.rb b/spec/requests/groups/observability_controller_spec.rb
index ea6e05435d5..70ebe2d22e8 100644
--- a/spec/requests/groups/observability_controller_spec.rb
+++ b/spec/requests/groups/observability_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Groups::ObservabilityController do
+RSpec.describe Groups::ObservabilityController, feature_category: :tracing do
let_it_be(:group) { create(:group) }
let_it_be(:user) { create(:user) }
diff --git a/spec/requests/groups/registry/repositories_controller_spec.rb b/spec/requests/groups/registry/repositories_controller_spec.rb
index 0699f48c2be..f54acf118bb 100644
--- a/spec/requests/groups/registry/repositories_controller_spec.rb
+++ b/spec/requests/groups/registry/repositories_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Groups::Registry::RepositoriesController do
+RSpec.describe Groups::Registry::RepositoriesController, feature_category: :container_registry do
let_it_be(:group, reload: true) { create(:group) }
let_it_be(:user) { create(:user) }
diff --git a/spec/requests/groups/settings/access_tokens_controller_spec.rb b/spec/requests/groups/settings/access_tokens_controller_spec.rb
index 6b150e0acb6..f26b69f8d30 100644
--- a/spec/requests/groups/settings/access_tokens_controller_spec.rb
+++ b/spec/requests/groups/settings/access_tokens_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Groups::Settings::AccessTokensController do
+RSpec.describe Groups::Settings::AccessTokensController, feature_category: :authentication_and_authorization do
let_it_be(:user) { create(:user) }
let_it_be(:resource) { create(:group) }
let_it_be(:access_token_user) { create(:user, :project_bot) }
diff --git a/spec/requests/groups/settings/applications_controller_spec.rb b/spec/requests/groups/settings/applications_controller_spec.rb
index 74313491414..fb91cd8bdab 100644
--- a/spec/requests/groups/settings/applications_controller_spec.rb
+++ b/spec/requests/groups/settings/applications_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Groups::Settings::ApplicationsController do
+RSpec.describe Groups::Settings::ApplicationsController, feature_category: :authentication_and_authorization do
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:application) { create(:oauth_application, owner_id: group.id, owner_type: 'Namespace') }
diff --git a/spec/requests/import/github_groups_controller_spec.rb b/spec/requests/import/github_groups_controller_spec.rb
index 544cbf88cd2..6393dd35a98 100644
--- a/spec/requests/import/github_groups_controller_spec.rb
+++ b/spec/requests/import/github_groups_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Import::GithubGroupsController do
+RSpec.describe Import::GithubGroupsController, feature_category: :importers do
describe 'GET status' do
subject(:status) { get '/import/github_group/status', params: params, headers: headers }
diff --git a/spec/requests/import/gitlab_groups_controller_spec.rb b/spec/requests/import/gitlab_groups_controller_spec.rb
index 8d5c1e3ebab..1766c48cca1 100644
--- a/spec/requests/import/gitlab_groups_controller_spec.rb
+++ b/spec/requests/import/gitlab_groups_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Import::GitlabGroupsController do
+RSpec.describe Import::GitlabGroupsController, feature_category: :importers do
include WorkhorseHelpers
include_context 'workhorse headers'
diff --git a/spec/requests/import/gitlab_projects_controller_spec.rb b/spec/requests/import/gitlab_projects_controller_spec.rb
index eed035608d0..b2c2d306e53 100644
--- a/spec/requests/import/gitlab_projects_controller_spec.rb
+++ b/spec/requests/import/gitlab_projects_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Import::GitlabProjectsController do
+RSpec.describe Import::GitlabProjectsController, feature_category: :importers do
include WorkhorseHelpers
include_context 'workhorse headers'
diff --git a/spec/requests/import/url_controller_spec.rb b/spec/requests/import/url_controller_spec.rb
index 63af5e8b469..fa2abda6711 100644
--- a/spec/requests/import/url_controller_spec.rb
+++ b/spec/requests/import/url_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Import::UrlController do
+RSpec.describe Import::UrlController, feature_category: :importers do
let_it_be(:user) { create(:user) }
before do
diff --git a/spec/requests/jira_connect/oauth_application_ids_controller_spec.rb b/spec/requests/jira_connect/oauth_application_ids_controller_spec.rb
index ed619bc50a7..d111edd06da 100644
--- a/spec/requests/jira_connect/oauth_application_ids_controller_spec.rb
+++ b/spec/requests/jira_connect/oauth_application_ids_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe JiraConnect::OauthApplicationIdsController do
+RSpec.describe JiraConnect::OauthApplicationIdsController, feature_category: :integrations do
describe 'GET /-/jira_connect/oauth_application_id' do
let(:cors_request_headers) { { 'Origin' => 'https://gitlab.com' } }
diff --git a/spec/requests/jira_connect/oauth_callbacks_controller_spec.rb b/spec/requests/jira_connect/oauth_callbacks_controller_spec.rb
index 12b9429b648..676b562c193 100644
--- a/spec/requests/jira_connect/oauth_callbacks_controller_spec.rb
+++ b/spec/requests/jira_connect/oauth_callbacks_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe JiraConnect::OauthCallbacksController do
+RSpec.describe JiraConnect::OauthCallbacksController, feature_category: :integrations do
describe 'GET /-/jira_connect/oauth_callbacks' do
context 'when logged in' do
it 'renders a page prompting the user to close the window' do
diff --git a/spec/requests/jira_connect/users_controller_spec.rb b/spec/requests/jira_connect/users_controller_spec.rb
index 6e927aaba91..c02bd324708 100644
--- a/spec/requests/jira_connect/users_controller_spec.rb
+++ b/spec/requests/jira_connect/users_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe JiraConnect::UsersController do
+RSpec.describe JiraConnect::UsersController, feature_category: :integrations do
describe 'GET /-/jira_connect/users' do
let_it_be(:user) { create(:user) }
diff --git a/spec/requests/mailgun/webhooks_controller_spec.rb b/spec/requests/mailgun/webhooks_controller_spec.rb
index ae6dc89d003..669401242b2 100644
--- a/spec/requests/mailgun/webhooks_controller_spec.rb
+++ b/spec/requests/mailgun/webhooks_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Mailgun::WebhooksController do
+RSpec.describe Mailgun::WebhooksController, feature_category: :team_planning do
let(:mailgun_signing_key) { 'abc123' }
let(:valid_signature) do
{
diff --git a/spec/requests/oauth/applications_controller_spec.rb b/spec/requests/oauth/applications_controller_spec.rb
index 78f0cedb56f..94ee08f6272 100644
--- a/spec/requests/oauth/applications_controller_spec.rb
+++ b/spec/requests/oauth/applications_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Oauth::ApplicationsController do
+RSpec.describe Oauth::ApplicationsController, feature_category: :authentication_and_authorization do
let_it_be(:user) { create(:user) }
let_it_be(:application) { create(:oauth_application, owner: user) }
let_it_be(:show_path) { oauth_application_path(application) }
diff --git a/spec/requests/oauth/authorizations_controller_spec.rb b/spec/requests/oauth/authorizations_controller_spec.rb
index 8d19c92865e..52188717210 100644
--- a/spec/requests/oauth/authorizations_controller_spec.rb
+++ b/spec/requests/oauth/authorizations_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Oauth::AuthorizationsController do
+RSpec.describe Oauth::AuthorizationsController, feature_category: :authentication_and_authorization do
let_it_be(:user) { create(:user) }
let_it_be(:application) { create(:oauth_application, redirect_uri: 'custom://test') }
let_it_be(:oauth_authorization_path) do
diff --git a/spec/requests/oauth/tokens_controller_spec.rb b/spec/requests/oauth/tokens_controller_spec.rb
index 507489d92cf..cdfad8cb59c 100644
--- a/spec/requests/oauth/tokens_controller_spec.rb
+++ b/spec/requests/oauth/tokens_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Oauth::TokensController do
+RSpec.describe Oauth::TokensController, feature_category: :authentication_and_authorization do
let(:cors_request_headers) { { 'Origin' => 'http://notgitlab.com' } }
let(:other_headers) { {} }
let(:headers) { cors_request_headers.merge(other_headers) }
diff --git a/spec/requests/profiles/notifications_controller_spec.rb b/spec/requests/profiles/notifications_controller_spec.rb
index d7dfb1c675d..21e166e04d3 100644
--- a/spec/requests/profiles/notifications_controller_spec.rb
+++ b/spec/requests/profiles/notifications_controller_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe 'view user notifications' do
+RSpec.describe 'view user notifications', feature_category: :team_planning do
let(:user) do
create(:user) do |user|
user.emails.create!(email: 'original@example.com', confirmed_at: Time.current)
diff --git a/spec/services/chat_names/find_user_service_spec.rb b/spec/services/chat_names/find_user_service_spec.rb
index b65a76ca37c..10cb0a2f065 100644
--- a/spec/services/chat_names/find_user_service_spec.rb
+++ b/spec/services/chat_names/find_user_service_spec.rb
@@ -4,17 +4,16 @@ require 'spec_helper'
RSpec.describe ChatNames::FindUserService, :clean_gitlab_redis_shared_state do
describe '#execute' do
- let(:integration) { create(:integration) }
-
- subject { described_class.new(integration, params).execute }
+ subject { described_class.new(team_id, user_id).execute }
context 'find user mapping' do
- let(:user) { create(:user) }
- let!(:chat_name) { create(:chat_name, user: user, integration: integration) }
+ let_it_be(:user) { create(:user) }
+ let_it_be(:chat_name) { create(:chat_name, user: user) }
- context 'when existing user is requested' do
- let(:params) { { team_id: chat_name.team_id, user_id: chat_name.chat_id } }
+ let(:team_id) { chat_name.team_id }
+ let(:user_id) { chat_name.chat_id }
+ context 'when existing user is requested' do
it 'returns the existing chat_name' do
is_expected.to eq(chat_name)
end
@@ -28,7 +27,8 @@ RSpec.describe ChatNames::FindUserService, :clean_gitlab_redis_shared_state do
end
it 'only updates an existing timestamp once within a certain time frame' do
- service = described_class.new(integration, params)
+ chat_name = create(:chat_name, user: user)
+ service = described_class.new(team_id, user_id)
expect(chat_name.last_used_at).to be_nil
@@ -40,20 +40,12 @@ RSpec.describe ChatNames::FindUserService, :clean_gitlab_redis_shared_state do
expect(chat_name.reload.last_used_at).to eq(time)
end
-
- context 'when integration is not passed' do
- it 'returns chat name' do
- requested_chat_name = described_class.new(nil, params).execute
-
- expect(requested_chat_name).to eq(chat_name)
- end
- end
end
context 'when different user is requested' do
- let(:params) { { team_id: chat_name.team_id, user_id: 'non-existing-user' } }
+ let(:user_id) { 'non-existing-user' }
- it 'returns existing user' do
+ it 'returns nil' do
is_expected.to be_nil
end
end
diff --git a/spec/services/groups/destroy_service_spec.rb b/spec/services/groups/destroy_service_spec.rb
index f2dbb69f855..2791203f395 100644
--- a/spec/services/groups/destroy_service_spec.rb
+++ b/spec/services/groups/destroy_service_spec.rb
@@ -8,8 +8,8 @@ RSpec.describe Groups::DestroyService do
let!(:nested_group) { create(:group, parent: group) }
let!(:project) { create(:project, :repository, :legacy_storage, namespace: group) }
let!(:notification_setting) { create(:notification_setting, source: group) }
- let(:gitlab_shell) { Gitlab::Shell.new }
let(:remove_path) { group.path + "+#{group.id}+deleted" }
+ let(:removed_repo) { Gitlab::Git::Repository.new(project.repository_storage, remove_path, nil, nil) }
before do
group.add_member(user, Gitlab::Access::OWNER)
@@ -70,8 +70,11 @@ RSpec.describe Groups::DestroyService do
end
it 'verifies that paths have been deleted' do
- expect(TestEnv.storage_dir_exists?(project.repository_storage, group.path)).to be_falsey
- expect(TestEnv.storage_dir_exists?(project.repository_storage, remove_path)).to be_falsey
+ Gitlab::GitalyClient::NamespaceService.allow do
+ expect(Gitlab::GitalyClient::NamespaceService.new(project.repository_storage)
+ .exists?(group.path)).to be_falsey
+ end
+ expect(removed_repo).not_to exist
end
end
end
@@ -98,8 +101,11 @@ RSpec.describe Groups::DestroyService do
end
it 'verifies original paths and projects still exist' do
- expect(TestEnv.storage_dir_exists?(project.repository_storage, group.path)).to be_truthy
- expect(TestEnv.storage_dir_exists?(project.repository_storage, remove_path)).to be_falsey
+ Gitlab::GitalyClient::NamespaceService.allow do
+ expect(Gitlab::GitalyClient::NamespaceService.new(project.repository_storage)
+ .exists?(group.path)).to be_truthy
+ end
+ expect(removed_repo).not_to exist
expect(Project.unscoped.count).to eq(1)
expect(Group.unscoped.count).to eq(2)
end
@@ -150,7 +156,7 @@ RSpec.describe Groups::DestroyService do
let!(:project) { create(:project, :legacy_storage, :empty_repo, namespace: group) }
it 'removes repository' do
- expect(gitlab_shell.repository_exists?(project.repository_storage, "#{project.disk_path}.git")).to be_falsey
+ expect(project.repository.raw).not_to exist
end
end
@@ -158,7 +164,7 @@ RSpec.describe Groups::DestroyService do
let!(:project) { create(:project, :empty_repo, namespace: group) }
it 'removes repository' do
- expect(gitlab_shell.repository_exists?(project.repository_storage, "#{project.disk_path}.git")).to be_falsey
+ expect(project.repository.raw).not_to exist
end
end
end
diff --git a/spec/services/projects/after_rename_service_spec.rb b/spec/services/projects/after_rename_service_spec.rb
index edf4bbe0f7f..72bb0adbf56 100644
--- a/spec/services/projects/after_rename_service_spec.rb
+++ b/spec/services/projects/after_rename_service_spec.rb
@@ -9,6 +9,16 @@ RSpec.describe Projects::AfterRenameService do
let!(:full_path_before_rename) { project.full_path }
let!(:path_after_rename) { "#{project.path}-renamed" }
let!(:full_path_after_rename) { "#{project.full_path}-renamed" }
+ let!(:repo_before_rename) { project.repository.raw }
+ let!(:wiki_repo_before_rename) { project.wiki.repository.raw }
+
+ let(:repo_after_rename) do
+ Gitlab::Git::Repository.new(project.repository_storage, "#{full_path_after_rename}.git", nil, nil)
+ end
+
+ let(:wiki_repo_after_rename) do
+ Gitlab::Git::Repository.new(project.repository_storage, "#{full_path_after_rename}.wiki.git", nil, nil)
+ end
describe '#execute' do
context 'using legacy storage' do
@@ -35,13 +45,15 @@ RSpec.describe Projects::AfterRenameService do
.to receive(:rename_project)
.with(path_before_rename, path_after_rename, project.namespace.full_path)
- expect_repository_exist("#{full_path_before_rename}.git")
- expect_repository_exist("#{full_path_before_rename}.wiki.git")
+ expect(repo_before_rename).to exist
+ expect(wiki_repo_before_rename).to exist
service_execute
- expect_repository_exist("#{full_path_after_rename}.git")
- expect_repository_exist("#{full_path_after_rename}.wiki.git")
+ expect(repo_before_rename).not_to exist
+ expect(wiki_repo_before_rename).not_to exist
+ expect(repo_after_rename).to exist
+ expect(wiki_repo_after_rename).to exist
end
context 'container registry with images' do
@@ -212,13 +224,4 @@ RSpec.describe Projects::AfterRenameService do
described_class.new(project, path_before: path_before_rename, full_path_before: full_path_before_rename).execute
end
-
- def expect_repository_exist(full_path_with_extension)
- expect(
- TestEnv.storage_dir_exists?(
- project.repository_storage,
- full_path_with_extension
- )
- ).to be_truthy
- end
end
diff --git a/spec/support/helpers/test_env.rb b/spec/support/helpers/test_env.rb
index 1bd468ccfc3..64c3972635d 100644
--- a/spec/support/helpers/test_env.rb
+++ b/spec/support/helpers/test_env.rb
@@ -313,12 +313,6 @@ module TestEnv
end
end
- def storage_dir_exists?(storage, dir)
- Gitlab::GitalyClient::StorageSettings.allow_disk_access do
- File.exist?(File.join(GitalySetup.repos_path(storage), dir))
- end
- end
-
def repos_path
@repos_path ||= GitalySetup.repos_path
end
diff --git a/spec/workers/repository_check/single_repository_worker_spec.rb b/spec/workers/repository_check/single_repository_worker_spec.rb
index b8db262598b..0a37a296e7a 100644
--- a/spec/workers/repository_check/single_repository_worker_spec.rb
+++ b/spec/workers/repository_check/single_repository_worker_spec.rb
@@ -98,16 +98,6 @@ RSpec.describe RepositoryCheck::SingleRepositoryWorker do
expect(project.reload.last_repository_check_failed).to eq(false)
end
- it 'does not create a wiki if the main repo does not exist at all' do
- project = create(:project, :repository)
- project.repository.raw.remove
- project.wiki.repository.raw.remove
-
- subject.perform(project.id)
-
- expect(TestEnv.storage_dir_exists?(project.repository_storage, project.wiki.path)).to eq(false)
- end
-
def create_push_event(project)
project.events.create!(action: :pushed, author_id: create(:user).id)
end