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:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/projects/pipelines_controller_spec.rb133
-rw-r--r--spec/frontend/alert_management/components/alert_details_spec.js2
-rw-r--r--spec/frontend/fixtures/test_report.rb1
-rw-r--r--spec/frontend/reports/components/grouped_test_reports_app_spec.js29
-rw-r--r--spec/lib/banzai/filter/gollum_tags_filter_spec.rb3
-rw-r--r--spec/lib/banzai/filter/wiki_link_filter_spec.rb3
-rw-r--r--spec/lib/banzai/pipeline/wiki_pipeline_spec.rb2
-rw-r--r--spec/lib/gitlab/usage_data_counters/track_unique_actions_spec.rb50
-rw-r--r--spec/lib/gitlab/usage_data_spec.rb16
-rw-r--r--spec/models/group_spec.rb44
-rw-r--r--spec/models/project_spec.rb24
-rw-r--r--spec/models/wiki_spec.rb14
-rw-r--r--spec/requests/api/ci/pipelines_spec.rb53
-rw-r--r--spec/services/alert_management/alerts/update_service_spec.rb3
-rw-r--r--spec/services/event_create_service_spec.rb10
-rw-r--r--spec/services/resource_access_tokens/create_service_spec.rb11
-rw-r--r--spec/services/todo_service_spec.rb30
17 files changed, 230 insertions, 198 deletions
diff --git a/spec/controllers/projects/pipelines_controller_spec.rb b/spec/controllers/projects/pipelines_controller_spec.rb
index 2f17cdd795a..ef560f6426b 100644
--- a/spec/controllers/projects/pipelines_controller_spec.rb
+++ b/spec/controllers/projects/pipelines_controller_spec.rb
@@ -859,113 +859,88 @@ RSpec.describe Projects::PipelinesController do
end
end
- context 'when feature is enabled' do
- before do
- stub_feature_flags(junit_pipeline_view: project)
- end
-
- context 'when pipeline does not have a test report' do
- it 'renders an empty test report' do
- get_test_report_json
+ context 'when pipeline does not have a test report' do
+ it 'renders an empty test report' do
+ get_test_report_json
- expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['total_count']).to eq(0)
- end
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response['total_count']).to eq(0)
end
+ end
- context 'when pipeline has a test report' do
- before do
- create(:ci_build, name: 'rspec', pipeline: pipeline).tap do |build|
- create(:ci_job_artifact, :junit, job: build)
- end
- end
-
- it 'renders the test report' do
- get_test_report_json
-
- expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['total_count']).to eq(4)
- end
+ context 'when pipeline has a test report' do
+ before do
+ create(:ci_build, :test_reports, name: 'rspec', pipeline: pipeline)
end
- context 'when pipeline has a corrupt test report artifact' do
- before do
- create(:ci_build, name: 'rspec', pipeline: pipeline).tap do |build|
- create(:ci_job_artifact, :junit_with_corrupted_data, job: build)
- end
+ it 'renders the test report' do
+ get_test_report_json
- get_test_report_json
- end
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response['total_count']).to eq(4)
+ end
+ end
- it 'renders the test reports' do
- expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['test_suites'].count).to eq(1)
- end
+ context 'when pipeline has a corrupt test report artifact' do
+ before do
+ create(:ci_build, :broken_test_reports, name: 'rspec', pipeline: pipeline)
- it 'returns a suite_error on the suite with corrupted XML' do
- expect(json_response['test_suites'].first['suite_error']).to eq('JUnit XML parsing failed: 1:1: FATAL: Document is empty')
- end
+ get_test_report_json
end
- context 'when junit_pipeline_screenshots_view is enabled' do
- before do
- stub_feature_flags(junit_pipeline_screenshots_view: project)
- end
-
- context 'when test_report contains attachment and scope is with_attachment as a URL param' do
- let(:pipeline) { create(:ci_pipeline, :with_test_reports_attachment, project: project) }
+ it 'renders the test reports' do
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response['test_suites'].count).to eq(1)
+ end
- it 'returns a test reports with attachment' do
- get_test_report_json(scope: 'with_attachment')
+ it 'returns a suite_error on the suite with corrupted XML' do
+ expect(json_response['test_suites'].first['suite_error']).to eq('JUnit XML parsing failed: 1:1: FATAL: Document is empty')
+ end
+ end
- expect(response).to have_gitlab_http_status(:ok)
- expect(json_response["test_suites"]).to be_present
- expect(json_response["test_suites"].first["test_cases"].first).to include("attachment_url")
- end
- end
+ context 'when junit_pipeline_screenshots_view is enabled' do
+ before do
+ stub_feature_flags(junit_pipeline_screenshots_view: project)
+ end
- context 'when test_report does not contain attachment and scope is with_attachment as a URL param' do
- let(:pipeline) { create(:ci_pipeline, :with_test_reports, project: project) }
+ context 'when test_report contains attachment and scope is with_attachment as a URL param' do
+ let(:pipeline) { create(:ci_pipeline, :with_test_reports_attachment, project: project) }
- it 'returns a test reports with empty values' do
- get_test_report_json(scope: 'with_attachment')
+ it 'returns a test reports with attachment' do
+ get_test_report_json(scope: 'with_attachment')
- expect(response).to have_gitlab_http_status(:ok)
- expect(json_response["test_suites"]).to be_empty
- end
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response["test_suites"]).to be_present
+ expect(json_response["test_suites"].first["test_cases"].first).to include("attachment_url")
end
end
- context 'when junit_pipeline_screenshots_view is disabled' do
- before do
- stub_feature_flags(junit_pipeline_screenshots_view: false)
- end
-
- context 'when test_report contains attachment and scope is with_attachment as a URL param' do
- let(:pipeline) { create(:ci_pipeline, :with_test_reports_attachment, project: project) }
+ context 'when test_report does not contain attachment and scope is with_attachment as a URL param' do
+ let(:pipeline) { create(:ci_pipeline, :with_test_reports, project: project) }
- it 'returns a test reports without attachment_url' do
- get_test_report_json(scope: 'with_attachment')
+ it 'returns a test reports with empty values' do
+ get_test_report_json(scope: 'with_attachment')
- expect(response).to have_gitlab_http_status(:ok)
- expect(json_response["test_suites"].first["test_cases"].first).not_to include("attachment_url")
- end
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response["test_suites"]).to be_empty
end
end
end
- context 'when feature is disabled' do
- let(:pipeline) { create(:ci_empty_pipeline, project: project) }
-
+ context 'when junit_pipeline_screenshots_view is disabled' do
before do
- stub_feature_flags(junit_pipeline_view: false)
+ stub_feature_flags(junit_pipeline_screenshots_view: false)
end
- it 'renders empty response' do
- get_test_report_json
+ context 'when test_report contains attachment and scope is with_attachment as a URL param' do
+ let(:pipeline) { create(:ci_pipeline, :with_test_reports_attachment, project: project) }
- expect(response).to have_gitlab_http_status(:no_content)
- expect(response.body).to be_empty
+ it 'returns a test reports without attachment_url' do
+ get_test_report_json(scope: 'with_attachment')
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response["test_suites"].first["test_cases"].first).not_to include("attachment_url")
+ end
end
end
diff --git a/spec/frontend/alert_management/components/alert_details_spec.js b/spec/frontend/alert_management/components/alert_details_spec.js
index 5364d662591..f91f08cae63 100644
--- a/spec/frontend/alert_management/components/alert_details_spec.js
+++ b/spec/frontend/alert_management/components/alert_details_spec.js
@@ -118,6 +118,8 @@ describe('AlertDetails', () => {
${'monitoringTool'} | ${undefined} | ${false}
${'service'} | ${'Prometheus'} | ${true}
${'service'} | ${undefined} | ${false}
+ ${'runbook'} | ${undefined} | ${false}
+ ${'runbook'} | ${'run.com'} | ${true}
`(`$desc`, ({ field, data, isShown }) => {
beforeEach(() => {
mountComponent({ data: { alert: { ...mockAlert, [field]: data } } });
diff --git a/spec/frontend/fixtures/test_report.rb b/spec/frontend/fixtures/test_report.rb
index 16496aa901b..3d09078ba68 100644
--- a/spec/frontend/fixtures/test_report.rb
+++ b/spec/frontend/fixtures/test_report.rb
@@ -15,7 +15,6 @@ RSpec.describe Projects::PipelinesController, "(JavaScript fixtures)", type: :co
before do
sign_in(user)
- stub_feature_flags(junit_pipeline_view: project)
end
it "pipelines/test_report.json" do
diff --git a/spec/frontend/reports/components/grouped_test_reports_app_spec.js b/spec/frontend/reports/components/grouped_test_reports_app_spec.js
index 017e0335569..c26e2fbc19a 100644
--- a/spec/frontend/reports/components/grouped_test_reports_app_spec.js
+++ b/spec/frontend/reports/components/grouped_test_reports_app_spec.js
@@ -20,10 +20,7 @@ describe('Grouped test reports app', () => {
let wrapper;
let mockStore;
- const mountComponent = ({
- glFeatures = { junitPipelineView: false },
- props = { pipelinePath },
- } = {}) => {
+ const mountComponent = ({ props = { pipelinePath } } = {}) => {
wrapper = mount(Component, {
store: mockStore,
localVue,
@@ -35,9 +32,6 @@ describe('Grouped test reports app', () => {
methods: {
fetchReports: () => {},
},
- provide: {
- glFeatures,
- },
});
};
@@ -78,28 +72,17 @@ describe('Grouped test reports app', () => {
});
describe('`View full report` button', () => {
- it('should not render the full test report link', () => {
- expect(findFullTestReportLink().exists()).toBe(false);
- });
+ it('should render the full test report link', () => {
+ const fullTestReportLink = findFullTestReportLink();
- describe('With junitPipelineView feature flag enabled', () => {
- beforeEach(() => {
- mountComponent({ glFeatures: { junitPipelineView: true } });
- });
-
- it('should render the full test report link', () => {
- const fullTestReportLink = findFullTestReportLink();
-
- expect(fullTestReportLink.exists()).toBe(true);
- expect(pipelinePath).not.toBe('');
- expect(fullTestReportLink.attributes('href')).toBe(`${pipelinePath}/test_report`);
- });
+ expect(fullTestReportLink.exists()).toBe(true);
+ expect(pipelinePath).not.toBe('');
+ expect(fullTestReportLink.attributes('href')).toBe(`${pipelinePath}/test_report`);
});
describe('Without a pipelinePath', () => {
beforeEach(() => {
mountComponent({
- glFeatures: { junitPipelineView: true },
props: { pipelinePath: '' },
});
});
diff --git a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb
index 2576dd1bf07..f39b5280490 100644
--- a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb
+++ b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb
@@ -6,8 +6,7 @@ RSpec.describe Banzai::Filter::GollumTagsFilter do
include FilterSpecHelper
let(:project) { create(:project) }
- let(:user) { double }
- let(:wiki) { ProjectWiki.new(project, user) }
+ let(:wiki) { ProjectWiki.new(project, nil) }
describe 'validation' do
it 'ensure that a :wiki key exists in context' do
diff --git a/spec/lib/banzai/filter/wiki_link_filter_spec.rb b/spec/lib/banzai/filter/wiki_link_filter_spec.rb
index 7a4464a2604..d1f6ee49260 100644
--- a/spec/lib/banzai/filter/wiki_link_filter_spec.rb
+++ b/spec/lib/banzai/filter/wiki_link_filter_spec.rb
@@ -7,8 +7,7 @@ RSpec.describe Banzai::Filter::WikiLinkFilter do
let(:namespace) { build_stubbed(:namespace, name: "wiki_link_ns") }
let(:project) { build_stubbed(:project, :public, name: "wiki_link_project", namespace: namespace) }
- let(:user) { double }
- let(:wiki) { ProjectWiki.new(project, user) }
+ let(:wiki) { ProjectWiki.new(project, nil) }
let(:repository_upload_folder) { Wikis::CreateAttachmentService::ATTACHMENT_PATH }
it "doesn't rewrite absolute links" do
diff --git a/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb
index 4af782c7d73..b102de24041 100644
--- a/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb
+++ b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb
@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Banzai::Pipeline::WikiPipeline do
let_it_be(:namespace) { create(:namespace, name: "wiki_link_ns") }
let_it_be(:project) { create(:project, :public, name: "wiki_link_project", namespace: namespace) }
- let_it_be(:wiki) { ProjectWiki.new(project, double(:user)) }
+ let_it_be(:wiki) { ProjectWiki.new(project, nil) }
let_it_be(:page) { build(:wiki_page, wiki: wiki, title: 'nested/twice/start-page') }
describe 'TableOfContents' do
diff --git a/spec/lib/gitlab/usage_data_counters/track_unique_actions_spec.rb b/spec/lib/gitlab/usage_data_counters/track_unique_actions_spec.rb
index 584d8407e79..6db77f19877 100644
--- a/spec/lib/gitlab/usage_data_counters/track_unique_actions_spec.rb
+++ b/spec/lib/gitlab/usage_data_counters/track_unique_actions_spec.rb
@@ -7,12 +7,12 @@ RSpec.describe Gitlab::UsageDataCounters::TrackUniqueActions, :clean_gitlab_redi
let(:time) { Time.zone.now }
- def track_action(params)
- track_unique_events.track_action(params)
+ def track_event(params)
+ track_unique_events.track_event(params)
end
- def count_unique_events(params)
- track_unique_events.count_unique_events(params)
+ def count_unique(params)
+ track_unique_events.count_unique(params)
end
context 'tracking an event' do
@@ -29,28 +29,28 @@ RSpec.describe Gitlab::UsageDataCounters::TrackUniqueActions, :clean_gitlab_redi
design = Event::TARGET_TYPES[:design]
wiki = Event::TARGET_TYPES[:wiki]
- expect(track_action(event_action: :pushed, event_target: project, author_id: 1)).to be_truthy
- expect(track_action(event_action: :pushed, event_target: project, author_id: 1)).to be_truthy
- expect(track_action(event_action: :pushed, event_target: project, author_id: 2)).to be_truthy
- expect(track_action(event_action: :pushed, event_target: project, author_id: 3)).to be_truthy
- expect(track_action(event_action: :pushed, event_target: project, author_id: 4, time: time - 3.days)).to be_truthy
- expect(track_action(event_action: :created, event_target: project, author_id: 5, time: time - 3.days)).to be_truthy
+ expect(track_event(event_action: :pushed, event_target: project, author_id: 1)).to be_truthy
+ expect(track_event(event_action: :pushed, event_target: project, author_id: 1)).to be_truthy
+ expect(track_event(event_action: :pushed, event_target: project, author_id: 2)).to be_truthy
+ expect(track_event(event_action: :pushed, event_target: project, author_id: 3)).to be_truthy
+ expect(track_event(event_action: :pushed, event_target: project, author_id: 4, time: time - 3.days)).to be_truthy
+ expect(track_event(event_action: :created, event_target: project, author_id: 5, time: time - 3.days)).to be_truthy
- expect(track_action(event_action: :destroyed, event_target: design, author_id: 3)).to be_truthy
- expect(track_action(event_action: :created, event_target: design, author_id: 4)).to be_truthy
- expect(track_action(event_action: :updated, event_target: design, author_id: 5)).to be_truthy
- expect(track_action(event_action: :pushed, event_target: design, author_id: 6)).to be_truthy
+ expect(track_event(event_action: :destroyed, event_target: design, author_id: 3)).to be_truthy
+ expect(track_event(event_action: :created, event_target: design, author_id: 4)).to be_truthy
+ expect(track_event(event_action: :updated, event_target: design, author_id: 5)).to be_truthy
+ expect(track_event(event_action: :pushed, event_target: design, author_id: 6)).to be_truthy
- expect(track_action(event_action: :destroyed, event_target: wiki, author_id: 5)).to be_truthy
- expect(track_action(event_action: :created, event_target: wiki, author_id: 3)).to be_truthy
- expect(track_action(event_action: :updated, event_target: wiki, author_id: 4)).to be_truthy
- expect(track_action(event_action: :pushed, event_target: wiki, author_id: 6)).to be_truthy
+ expect(track_event(event_action: :destroyed, event_target: wiki, author_id: 5)).to be_truthy
+ expect(track_event(event_action: :created, event_target: wiki, author_id: 3)).to be_truthy
+ expect(track_event(event_action: :updated, event_target: wiki, author_id: 4)).to be_truthy
+ expect(track_event(event_action: :pushed, event_target: wiki, author_id: 6)).to be_truthy
- expect(count_unique_events(event_action: described_class::PUSH_ACTION, date_from: time, date_to: Date.today)).to eq(3)
- expect(count_unique_events(event_action: described_class::PUSH_ACTION, date_from: time - 5.days, date_to: Date.tomorrow)).to eq(4)
- expect(count_unique_events(event_action: described_class::DESIGN_ACTION, date_from: time - 5.days, date_to: Date.today)).to eq(3)
- expect(count_unique_events(event_action: described_class::WIKI_ACTION, date_from: time - 5.days, date_to: Date.today)).to eq(3)
- expect(count_unique_events(event_action: described_class::PUSH_ACTION, date_from: time - 5.days, date_to: time - 2.days)).to eq(1)
+ expect(count_unique(event_action: described_class::PUSH_ACTION, date_from: time, date_to: Date.today)).to eq(3)
+ expect(count_unique(event_action: described_class::PUSH_ACTION, date_from: time - 5.days, date_to: Date.tomorrow)).to eq(4)
+ expect(count_unique(event_action: described_class::DESIGN_ACTION, date_from: time - 5.days, date_to: Date.today)).to eq(3)
+ expect(count_unique(event_action: described_class::WIKI_ACTION, date_from: time - 5.days, date_to: Date.today)).to eq(3)
+ expect(count_unique(event_action: described_class::PUSH_ACTION, date_from: time - 5.days, date_to: time - 2.days)).to eq(1)
end
end
end
@@ -73,8 +73,8 @@ RSpec.describe Gitlab::UsageDataCounters::TrackUniqueActions, :clean_gitlab_redi
end
it 'returns the expected values' do
- expect(track_action(event_action: action, event_target: target, author_id: 2)).to be_nil
- expect(count_unique_events(event_action: described_class::PUSH_ACTION, date_from: time, date_to: Date.today)).to eq(0)
+ expect(track_event(event_action: action, event_target: target, author_id: 2)).to be_nil
+ expect(count_unique(event_action: described_class::PUSH_ACTION, date_from: time, date_to: Date.today)).to eq(0)
end
end
end
diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb
index 681784369e0..2fb30b3228a 100644
--- a/spec/lib/gitlab/usage_data_spec.rb
+++ b/spec/lib/gitlab/usage_data_spec.rb
@@ -924,14 +924,14 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
wiki = Event::TARGET_TYPES[:wiki]
design = Event::TARGET_TYPES[:design]
- counter.track_action(event_action: :pushed, event_target: project, author_id: 1)
- counter.track_action(event_action: :pushed, event_target: project, author_id: 1)
- counter.track_action(event_action: :pushed, event_target: project, author_id: 2)
- counter.track_action(event_action: :pushed, event_target: project, author_id: 3)
- counter.track_action(event_action: :pushed, event_target: project, author_id: 4, time: time - 3.days)
- counter.track_action(event_action: :created, event_target: project, author_id: 5, time: time - 3.days)
- counter.track_action(event_action: :created, event_target: wiki, author_id: 3)
- counter.track_action(event_action: :created, event_target: design, author_id: 3)
+ counter.track_event(event_action: :pushed, event_target: project, author_id: 1)
+ counter.track_event(event_action: :pushed, event_target: project, author_id: 1)
+ counter.track_event(event_action: :pushed, event_target: project, author_id: 2)
+ counter.track_event(event_action: :pushed, event_target: project, author_id: 3)
+ counter.track_event(event_action: :pushed, event_target: project, author_id: 4, time: time - 3.days)
+ counter.track_event(event_action: :created, event_target: project, author_id: 5, time: time - 3.days)
+ counter.track_event(event_action: :created, event_target: wiki, author_id: 3)
+ counter.track_event(event_action: :created, event_target: design, author_id: 3)
end
it 'returns the distinct count of user actions within the specified time period' do
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index dfc51ff377b..3eb74da09e1 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -1541,4 +1541,48 @@ RSpec.describe Group do
end
end
end
+
+ describe '#default_owner' do
+ let(:group) { build(:group) }
+
+ context 'the group has owners' do
+ before do
+ group.add_owner(create(:user))
+ group.add_owner(create(:user))
+ end
+
+ it 'is the first owner' do
+ expect(group.default_owner)
+ .to eq(group.owners.first)
+ .and be_a(User)
+ end
+ end
+
+ context 'the group has a parent' do
+ let(:parent) { build(:group) }
+
+ before do
+ group.parent = parent
+ parent.add_owner(create(:user))
+ end
+
+ it 'is the first owner of the parent' do
+ expect(group.default_owner)
+ .to eq(parent.default_owner)
+ .and be_a(User)
+ end
+ end
+
+ context 'we fallback to group.owner' do
+ before do
+ group.owner = build(:user)
+ end
+
+ it 'is the group.owner' do
+ expect(group.default_owner)
+ .to eq(group.owner)
+ .and be_a(User)
+ end
+ end
+ end
end
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index e6d51e0bfd7..f589589af8f 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -1090,6 +1090,30 @@ RSpec.describe Project do
end
end
+ describe '#default_owner' do
+ let_it_be(:owner) { create(:user) }
+ let_it_be(:namespace) { create(:namespace, owner: owner) }
+
+ context 'the project does not have a group' do
+ let(:project) { build(:project, namespace: namespace) }
+
+ it 'is the namespace owner' do
+ expect(project.default_owner).to eq(owner)
+ end
+ end
+
+ context 'the project is in a group' do
+ let(:group) { build(:group) }
+ let(:project) { build(:project, group: group, namespace: namespace) }
+
+ it 'is the group owner' do
+ allow(group).to receive(:default_owner).and_return(Object.new)
+
+ expect(project.default_owner).to eq(group.default_owner)
+ end
+ end
+ end
+
describe '#external_wiki' do
let(:project) { create(:project) }
diff --git a/spec/models/wiki_spec.rb b/spec/models/wiki_spec.rb
new file mode 100644
index 00000000000..8dd510a0b98
--- /dev/null
+++ b/spec/models/wiki_spec.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+require "spec_helper"
+
+RSpec.describe Wiki do
+ describe '.new' do
+ it 'verifies that the user is a User' do
+ expect { described_class.new(double, 1) }.to raise_error(ArgumentError)
+ expect { described_class.new(double, build(:group)) }.to raise_error(ArgumentError)
+ expect { described_class.new(double, build(:user)) }.not_to raise_error
+ expect { described_class.new(double, nil) }.not_to raise_error
+ end
+ end
+end
diff --git a/spec/requests/api/ci/pipelines_spec.rb b/spec/requests/api/ci/pipelines_spec.rb
index 6ab00f96092..111bc933ea4 100644
--- a/spec/requests/api/ci/pipelines_spec.rb
+++ b/spec/requests/api/ci/pipelines_spec.rb
@@ -735,55 +735,36 @@ RSpec.describe API::Ci::Pipelines do
let(:pipeline) { create(:ci_pipeline, project: project) }
- context 'when feature is enabled' do
- before do
- stub_feature_flags(junit_pipeline_view: true)
- end
-
- context 'when pipeline does not have a test report' do
- it 'returns an empty test report' do
- subject
-
- expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['total_count']).to eq(0)
- end
- end
-
- context 'when pipeline has a test report' do
- let(:pipeline) { create(:ci_pipeline, :with_test_reports, project: project) }
-
- it 'returns the test report' do
- subject
+ context 'when pipeline does not have a test report' do
+ it 'returns an empty test report' do
+ subject
- expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['total_count']).to eq(4)
- end
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response['total_count']).to eq(0)
end
+ end
- context 'when pipeline has corrupt test reports' do
- before do
- job = create(:ci_build, pipeline: pipeline)
- create(:ci_job_artifact, :junit_with_corrupted_data, job: job, project: project)
- end
+ context 'when pipeline has a test report' do
+ let(:pipeline) { create(:ci_pipeline, :with_test_reports, project: project) }
- it 'returns a suite_error' do
- subject
+ it 'returns the test report' do
+ subject
- expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['test_suites'].first['suite_error']).to eq('JUnit XML parsing failed: 1:1: FATAL: Document is empty')
- end
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response['total_count']).to eq(4)
end
end
- context 'when feature is disabled' do
+ context 'when pipeline has corrupt test reports' do
before do
- stub_feature_flags(junit_pipeline_view: false)
+ create(:ci_build, :broken_test_reports, name: 'rspec', pipeline: pipeline)
end
- it 'renders empty response' do
+ it 'returns a suite_error' do
subject
- expect(response).to have_gitlab_http_status(:not_found)
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response['test_suites'].first['suite_error']).to eq('JUnit XML parsing failed: 1:1: FATAL: Document is empty')
end
end
end
diff --git a/spec/services/alert_management/alerts/update_service_spec.rb b/spec/services/alert_management/alerts/update_service_spec.rb
index 91b02325bad..ee04fc55984 100644
--- a/spec/services/alert_management/alerts/update_service_spec.rb
+++ b/spec/services/alert_management/alerts/update_service_spec.rb
@@ -147,8 +147,7 @@ RSpec.describe AlertManagement::Alerts::UpdateService do
end
it_behaves_like 'does not add a system note'
- # TODO: We should not add another todo in this scenario
- it_behaves_like 'adds a todo'
+ it_behaves_like 'does not add a todo'
end
context 'with multiple users included' do
diff --git a/spec/services/event_create_service_spec.rb b/spec/services/event_create_service_spec.rb
index 57382b7e5a0..edd585cb4b6 100644
--- a/spec/services/event_create_service_spec.rb
+++ b/spec/services/event_create_service_spec.rb
@@ -207,7 +207,7 @@ RSpec.describe EventCreateService do
tracking_params = { event_action: counter_class::WIKI_ACTION, date_from: Date.yesterday, date_to: Date.today }
expect { create_event }
- .to change { counter_class.count_unique_events(tracking_params) }
+ .to change { counter_class.count_unique(tracking_params) }
.by(1)
end
end
@@ -249,7 +249,7 @@ RSpec.describe EventCreateService do
tracking_params = { event_action: counter_class::PUSH_ACTION, date_from: Date.yesterday, date_to: Date.today }
expect { subject }
- .to change { counter_class.count_unique_events(tracking_params) }
+ .to change { counter_class.count_unique(tracking_params) }
.from(0).to(1)
end
end
@@ -273,7 +273,7 @@ RSpec.describe EventCreateService do
tracking_params = { event_action: counter_class::PUSH_ACTION, date_from: Date.yesterday, date_to: Date.today }
expect { subject }
- .to change { counter_class.count_unique_events(tracking_params) }
+ .to change { counter_class.count_unique(tracking_params) }
.from(0).to(1)
end
end
@@ -328,7 +328,7 @@ RSpec.describe EventCreateService do
tracking_params = { event_action: counter_class::DESIGN_ACTION, date_from: Date.yesterday, date_to: Date.today }
expect { result }
- .to change { counter_class.count_unique_events(tracking_params) }
+ .to change { counter_class.count_unique(tracking_params) }
.from(0).to(1)
end
end
@@ -356,7 +356,7 @@ RSpec.describe EventCreateService do
tracking_params = { event_action: counter_class::DESIGN_ACTION, date_from: Date.yesterday, date_to: Date.today }
expect { result }
- .to change { counter_class.count_unique_events(tracking_params) }
+ .to change { counter_class.count_unique(tracking_params) }
.from(0).to(1)
end
end
diff --git a/spec/services/resource_access_tokens/create_service_spec.rb b/spec/services/resource_access_tokens/create_service_spec.rb
index f22c379cd30..7dbd55a6909 100644
--- a/spec/services/resource_access_tokens/create_service_spec.rb
+++ b/spec/services/resource_access_tokens/create_service_spec.rb
@@ -34,6 +34,16 @@ RSpec.describe ResourceAccessTokens::CreateService do
end
end
+ shared_examples 'fails on gitlab.com' do
+ before do
+ allow(Gitlab).to receive(:com?) { true }
+ end
+
+ it 'returns nil' do
+ expect(subject).to be nil
+ end
+ end
+
shared_examples 'allows creation of bot with valid params' do
it { expect { subject }.to change { User.count }.by(1) }
@@ -171,6 +181,7 @@ RSpec.describe ResourceAccessTokens::CreateService do
it_behaves_like 'fails when user does not have the permission to create a Resource Bot'
it_behaves_like 'fails when flag is disabled'
+ it_behaves_like 'fails on gitlab.com'
context 'user with valid permission' do
before_all do
diff --git a/spec/services/todo_service_spec.rb b/spec/services/todo_service_spec.rb
index 13da76263b1..94d4b61933d 100644
--- a/spec/services/todo_service_spec.rb
+++ b/spec/services/todo_service_spec.rb
@@ -59,6 +59,10 @@ RSpec.describe TodoService do
should_not_create_todo(user: guest, target: addressed_target_assigned, action: Todo::DIRECTLY_ADDRESSED)
end
+
+ it 'does not create a todo if already assigned' do
+ should_not_create_any_todo { service.send(described_method, target_assigned, author, [john_doe]) }
+ end
end
describe 'Issues' do
@@ -573,10 +577,10 @@ RSpec.describe TodoService do
end
end
- describe '#reassigned_issuable' do
- let(:described_method) { :reassigned_issuable }
+ describe '#reassigned_assignable' do
+ let(:described_method) { :reassigned_assignable }
- context 'issuable is a merge request' do
+ context 'assignable is a merge request' do
it_behaves_like 'reassigned target' do
let(:target_assigned) { create(:merge_request, source_project: project, author: author, assignees: [john_doe], description: "- [ ] Task 1\n- [ ] Task 2 #{mentions}") }
let(:addressed_target_assigned) { create(:merge_request, source_project: project, author: author, assignees: [john_doe], description: "#{directly_addressed}\n- [ ] Task 1\n- [ ] Task 2") }
@@ -584,13 +588,21 @@ RSpec.describe TodoService do
end
end
- context 'issuable is an issue' do
+ context 'assignable is an issue' do
it_behaves_like 'reassigned target' do
let(:target_assigned) { create(:issue, project: project, author: author, assignees: [john_doe], description: "- [ ] Task 1\n- [ ] Task 2 #{mentions}") }
let(:addressed_target_assigned) { create(:issue, project: project, author: author, assignees: [john_doe], description: "#{directly_addressed}\n- [ ] Task 1\n- [ ] Task 2") }
let(:target_unassigned) { create(:issue, project: project, author: author, assignees: []) }
end
end
+
+ context 'assignable is an alert' do
+ it_behaves_like 'reassigned target' do
+ let(:target_assigned) { create(:alert_management_alert, project: project, assignees: [john_doe]) }
+ let(:addressed_target_assigned) { create(:alert_management_alert, project: project, assignees: [john_doe]) }
+ let(:target_unassigned) { create(:alert_management_alert, project: project, assignees: []) }
+ end
+ end
end
describe 'Merge Requests' do
@@ -778,16 +790,6 @@ RSpec.describe TodoService do
end
end
- describe '#assign_alert' do
- let(:described_method) { :assign_alert }
-
- it_behaves_like 'reassigned target' do
- let(:target_assigned) { create(:alert_management_alert, project: project, assignees: [john_doe]) }
- let(:addressed_target_assigned) { create(:alert_management_alert, project: project, assignees: [john_doe]) }
- let(:target_unassigned) { create(:alert_management_alert, project: project, assignees: []) }
- end
- end
-
describe '#merge_request_build_failed' do
let(:merge_participants) { [mr_unassigned.author, admin] }