Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-07-27 12:10:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-07-27 12:10:42 +0300
commit5add82515889cf332b65bbf59394079222dc66b3 (patch)
tree95c6e3092407fb86a39dab4ffafc930a6fb95bec /spec
parent1d9c7ebdadc0c011b997bc8e0032281b939de4e7 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/concerns/product_analytics_tracking_spec.rb2
-rw-r--r--spec/frontend/pipelines/pipeline_graph/utils_spec.js6
-rw-r--r--spec/lib/generators/gitlab/snowplow_event_definition_generator_spec.rb2
-rw-r--r--spec/lib/gitlab/analytics/cycle_analytics/stage_events/stage_event_spec.rb2
-rw-r--r--spec/lib/gitlab/internal_events/event_definitions_spec.rb2
-rw-r--r--spec/lib/gitlab/internal_events_spec.rb2
-rw-r--r--spec/lib/product_analytics/settings_spec.rb2
-rw-r--r--spec/migrations/20221219122320_copy_clickhouse_connection_string_to_encrypted_var_spec.rb2
-rw-r--r--spec/migrations/20230327123333_backfill_product_analytics_data_collector_host_spec.rb2
-rw-r--r--spec/models/group_spec.rb7
-rw-r--r--spec/services/notes/quick_actions_service_spec.rb56
-rw-r--r--spec/services/product_analytics/build_activity_graph_service_spec.rb2
-rw-r--r--spec/services/product_analytics/build_graph_service_spec.rb2
-rw-r--r--spec/services/projects/destroy_service_spec.rb17
-rw-r--r--spec/services/quick_actions/interpret_service_spec.rb14
15 files changed, 101 insertions, 19 deletions
diff --git a/spec/controllers/concerns/product_analytics_tracking_spec.rb b/spec/controllers/concerns/product_analytics_tracking_spec.rb
index 65c2c77c027..0f18a4fed9e 100644
--- a/spec/controllers/concerns/product_analytics_tracking_spec.rb
+++ b/spec/controllers/concerns/product_analytics_tracking_spec.rb
@@ -2,7 +2,7 @@
require "spec_helper"
-RSpec.describe ProductAnalyticsTracking, :snowplow, feature_category: :product_analytics do
+RSpec.describe ProductAnalyticsTracking, :snowplow, feature_category: :product_analytics_data_management do
include TrackingHelpers
include SnowplowHelpers
diff --git a/spec/frontend/pipelines/pipeline_graph/utils_spec.js b/spec/frontend/pipelines/pipeline_graph/utils_spec.js
index 41b020189d0..96b18fcf96f 100644
--- a/spec/frontend/pipelines/pipeline_graph/utils_spec.js
+++ b/spec/frontend/pipelines/pipeline_graph/utils_spec.js
@@ -1,5 +1,5 @@
import { createJobsHash, generateJobNeedsDict, getPipelineDefaultTab } from '~/pipelines/utils';
-import { validPipelineTabNames } from '~/pipelines/constants';
+import { validPipelineTabNames, pipelineTabName } from '~/pipelines/constants';
describe('utils functions', () => {
const jobName1 = 'build_1';
@@ -173,8 +173,8 @@ describe('utils functions', () => {
describe('getPipelineDefaultTab', () => {
const baseUrl = 'http://gitlab.com/user/multi-projects-small/-/pipelines/332/';
- it('returns null if there is only the base url', () => {
- expect(getPipelineDefaultTab(baseUrl)).toBe(null);
+ it('returns pipeline tab name if there is only the base url', () => {
+ expect(getPipelineDefaultTab(baseUrl)).toBe(pipelineTabName);
});
it('returns null if there was no valid last url part', () => {
diff --git a/spec/lib/generators/gitlab/snowplow_event_definition_generator_spec.rb b/spec/lib/generators/gitlab/snowplow_event_definition_generator_spec.rb
index 6826006949e..62a52ee5fb9 100644
--- a/spec/lib/generators/gitlab/snowplow_event_definition_generator_spec.rb
+++ b/spec/lib/generators/gitlab/snowplow_event_definition_generator_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Gitlab::SnowplowEventDefinitionGenerator, :silence_stdout, feature_category: :product_analytics do
+RSpec.describe Gitlab::SnowplowEventDefinitionGenerator, :silence_stdout, feature_category: :product_analytics_data_management do
let(:ce_temp_dir) { Dir.mktmpdir }
let(:ee_temp_dir) { Dir.mktmpdir }
let(:timestamp) { Time.now.utc.strftime('%Y%m%d%H%M%S') }
diff --git a/spec/lib/gitlab/analytics/cycle_analytics/stage_events/stage_event_spec.rb b/spec/lib/gitlab/analytics/cycle_analytics/stage_events/stage_event_spec.rb
index 24248c557bd..df0e4fb92a0 100644
--- a/spec/lib/gitlab/analytics/cycle_analytics/stage_events/stage_event_spec.rb
+++ b/spec/lib/gitlab/analytics/cycle_analytics/stage_events/stage_event_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Gitlab::Analytics::CycleAnalytics::StageEvents::StageEvent, feature_category: :product_analytics do
+RSpec.describe Gitlab::Analytics::CycleAnalytics::StageEvents::StageEvent, feature_category: :product_analytics_data_management do
let(:instance) { described_class.new({}) }
it { expect(described_class).to respond_to(:name) }
diff --git a/spec/lib/gitlab/internal_events/event_definitions_spec.rb b/spec/lib/gitlab/internal_events/event_definitions_spec.rb
index 0eba3cdbcb3..924845504ca 100644
--- a/spec/lib/gitlab/internal_events/event_definitions_spec.rb
+++ b/spec/lib/gitlab/internal_events/event_definitions_spec.rb
@@ -2,7 +2,7 @@
require "spec_helper"
-RSpec.describe Gitlab::InternalEvents::EventDefinitions, feature_category: :product_analytics do
+RSpec.describe Gitlab::InternalEvents::EventDefinitions, feature_category: :product_analytics_data_management do
after(:all) do
described_class.instance_variable_set(:@events, nil)
end
diff --git a/spec/lib/gitlab/internal_events_spec.rb b/spec/lib/gitlab/internal_events_spec.rb
index 86215434ba4..c2615e0f22c 100644
--- a/spec/lib/gitlab/internal_events_spec.rb
+++ b/spec/lib/gitlab/internal_events_spec.rb
@@ -2,7 +2,7 @@
require "spec_helper"
-RSpec.describe Gitlab::InternalEvents, :snowplow, feature_category: :product_analytics do
+RSpec.describe Gitlab::InternalEvents, :snowplow, feature_category: :product_analytics_data_management do
include TrackingHelpers
include SnowplowHelpers
diff --git a/spec/lib/product_analytics/settings_spec.rb b/spec/lib/product_analytics/settings_spec.rb
index 9c33b8068d1..9ba5dbfc8fc 100644
--- a/spec/lib/product_analytics/settings_spec.rb
+++ b/spec/lib/product_analytics/settings_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe ProductAnalytics::Settings, feature_category: :product_analytics do
+RSpec.describe ProductAnalytics::Settings, feature_category: :product_analytics_data_management do
let_it_be(:project) { create(:project) }
subject { described_class.for_project(project) }
diff --git a/spec/migrations/20221219122320_copy_clickhouse_connection_string_to_encrypted_var_spec.rb b/spec/migrations/20221219122320_copy_clickhouse_connection_string_to_encrypted_var_spec.rb
index 7ff033ab0c2..48702e866e0 100644
--- a/spec/migrations/20221219122320_copy_clickhouse_connection_string_to_encrypted_var_spec.rb
+++ b/spec/migrations/20221219122320_copy_clickhouse_connection_string_to_encrypted_var_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
require_migration!
-RSpec.describe CopyClickhouseConnectionStringToEncryptedVar, feature_category: :product_analytics do
+RSpec.describe CopyClickhouseConnectionStringToEncryptedVar, feature_category: :product_analytics_data_management do
let!(:migration) { described_class.new }
let(:setting) { table(:application_settings).create!(clickhouse_connection_string: 'https://example.com/test') }
diff --git a/spec/migrations/20230327123333_backfill_product_analytics_data_collector_host_spec.rb b/spec/migrations/20230327123333_backfill_product_analytics_data_collector_host_spec.rb
index 253512c9194..05cc065e6c3 100644
--- a/spec/migrations/20230327123333_backfill_product_analytics_data_collector_host_spec.rb
+++ b/spec/migrations/20230327123333_backfill_product_analytics_data_collector_host_spec.rb
@@ -3,7 +3,7 @@
require "spec_helper"
require_migration!
-RSpec.describe BackfillProductAnalyticsDataCollectorHost, feature_category: :product_analytics do
+RSpec.describe BackfillProductAnalyticsDataCollectorHost, feature_category: :product_analytics_data_management do
let!(:application_settings) { table(:application_settings) }
describe '#up' do
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index db5750b2019..eb604456511 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -390,6 +390,13 @@ RSpec.describe Group, feature_category: :groups_and_projects do
expect(internal_group).to be_invalid
expect(internal_group.errors[:visibility_level]).to include('private is not allowed since this group contains projects with higher visibility.')
end
+
+ it 'is valid if higher visibility project is deleted' do
+ internal_project.update_attribute(:pending_delete, true)
+ internal_group.visibility_level = Gitlab::VisibilityLevel::PRIVATE
+
+ expect(internal_group).to be_valid
+ end
end
context 'when group has a higher visibility' do
diff --git a/spec/services/notes/quick_actions_service_spec.rb b/spec/services/notes/quick_actions_service_spec.rb
index c51e381014d..0065fd639b8 100644
--- a/spec/services/notes/quick_actions_service_spec.rb
+++ b/spec/services/notes/quick_actions_service_spec.rb
@@ -132,13 +132,59 @@ RSpec.describe Notes::QuickActionsService, feature_category: :team_planning do
end
describe '/estimate' do
- let(:note_text) { '/estimate 1h' }
+ before do
+ # reset to 10 minutes before each test
+ note.noteable.update!(time_estimate: 600)
+ end
+
+ shared_examples 'does not update time_estimate and displays the correct error message' do
+ it 'shows validation error message' do
+ content = execute(note)
+
+ expect(content).to be_empty
+ expect(note.noteable.errors[:time_estimate]).to include('must have a valid format and be greater than or equal to zero.')
+ expect(note.noteable.reload.time_estimate).to eq(600)
+ end
+ end
+
+ context 'when the time estimate is valid' do
+ let(:note_text) { '/estimate 1h' }
+
+ it 'adds time estimate to noteable' do
+ content = execute(note)
+
+ expect(content).to be_empty
+ expect(note.noteable.reload.time_estimate).to eq(3600)
+ end
+ end
+
+ context 'when the time estimate is 0' do
+ let(:note_text) { '/estimate 0' }
+
+ it 'adds time estimate to noteable' do
+ content = execute(note)
+
+ expect(content).to be_empty
+ expect(note.noteable.reload.time_estimate).to eq(0)
+ end
+ end
+
+ context 'when the time estimate is invalid' do
+ let(:note_text) { '/estimate a' }
+
+ include_examples "does not update time_estimate and displays the correct error message"
+ end
+
+ context 'when the time estimate is partially invalid' do
+ let(:note_text) { '/estimate 1d 3id' }
+
+ include_examples "does not update time_estimate and displays the correct error message"
+ end
- it 'adds time estimate to noteable' do
- content = execute(note)
+ context 'when the time estimate is negative' do
+ let(:note_text) { '/estimate -1h' }
- expect(content).to be_empty
- expect(note.noteable.time_estimate).to eq(3600)
+ include_examples "does not update time_estimate and displays the correct error message"
end
end
diff --git a/spec/services/product_analytics/build_activity_graph_service_spec.rb b/spec/services/product_analytics/build_activity_graph_service_spec.rb
index cd1bc42e156..2eb35523da7 100644
--- a/spec/services/product_analytics/build_activity_graph_service_spec.rb
+++ b/spec/services/product_analytics/build_activity_graph_service_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe ProductAnalytics::BuildActivityGraphService, feature_category: :product_analytics do
+RSpec.describe ProductAnalytics::BuildActivityGraphService, feature_category: :product_analytics_data_management do
let_it_be(:project) { create(:project) }
let_it_be(:time_now) { Time.zone.now }
let_it_be(:time_ago) { Time.zone.now - 5.days }
diff --git a/spec/services/product_analytics/build_graph_service_spec.rb b/spec/services/product_analytics/build_graph_service_spec.rb
index ee0e2190501..13c7206241c 100644
--- a/spec/services/product_analytics/build_graph_service_spec.rb
+++ b/spec/services/product_analytics/build_graph_service_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe ProductAnalytics::BuildGraphService, feature_category: :product_analytics do
+RSpec.describe ProductAnalytics::BuildGraphService, feature_category: :product_analytics_data_management do
let_it_be(:project) { create(:project) }
let_it_be(:events) do
diff --git a/spec/services/projects/destroy_service_spec.rb b/spec/services/projects/destroy_service_spec.rb
index ccf58964c71..0210e101e5f 100644
--- a/spec/services/projects/destroy_service_spec.rb
+++ b/spec/services/projects/destroy_service_spec.rb
@@ -115,6 +115,23 @@ RSpec.describe Projects::DestroyService, :aggregate_failures, :event_store_publi
expect(project.reload.delete_error).to be_present
expect(project.delete_error).to match(error_message)
end
+
+ context 'when parent group visibility was made more restrictive while project was marked "pending deletion"' do
+ let!(:group) { create(:group, :public) }
+ let!(:project) { create(:project, :repository, :public, namespace: group) }
+
+ it 'sets the project visibility level to that of the parent group' do
+ group.add_owner(user)
+ project.group.update_attribute(:visibility_level, Gitlab::VisibilityLevel::INTERNAL)
+
+ expect(project.reload.visibility_level).to be(Gitlab::VisibilityLevel::PUBLIC)
+ expect(project.group.visibility_level).to be(Gitlab::VisibilityLevel::INTERNAL)
+
+ destroy_project(project, user, {})
+
+ expect(project.reload.visibility_level).to be(Gitlab::VisibilityLevel::INTERNAL)
+ end
+ end
end
context "deleting a project with merge requests" do
diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb
index 186b532233e..86e2340b9fb 100644
--- a/spec/services/quick_actions/interpret_service_spec.rb
+++ b/spec/services/quick_actions/interpret_service_spec.rb
@@ -1454,9 +1454,21 @@ RSpec.describe QuickActions::InterpretService, feature_category: :team_planning
let(:issuable) { issue }
end
- it_behaves_like 'failed command' do
+ context 'when provided an invalid estimate' do
let(:content) { '/estimate abc' }
let(:issuable) { issue }
+
+ it 'populates {} if content contains an unsupported command' do
+ _, updates, _ = service.execute(content, issuable)
+
+ expect(updates[:time_estimate]).to be_nil
+ end
+
+ it "returns empty message" do
+ _, _, message = service.execute(content, issuable)
+
+ expect(message).to be_empty
+ end
end
it_behaves_like 'spend command' do