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
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/services
parent1d9c7ebdadc0c011b997bc8e0032281b939de4e7 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-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
5 files changed, 83 insertions, 8 deletions
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