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:
Diffstat (limited to 'spec/services/notes')
-rw-r--r--spec/services/notes/create_service_spec.rb2
-rw-r--r--spec/services/notes/destroy_service_spec.rb4
-rw-r--r--spec/services/notes/quick_actions_service_spec.rb79
-rw-r--r--spec/services/notes/update_service_spec.rb2
4 files changed, 83 insertions, 4 deletions
diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb
index b5eb5f8037a..0cc66696184 100644
--- a/spec/services/notes/create_service_spec.rb
+++ b/spec/services/notes/create_service_spec.rb
@@ -181,7 +181,7 @@ RSpec.describe Notes::CreateService, feature_category: :team_planning do
end
it_behaves_like 'internal event tracking' do
- let(:action) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_ADDED }
+ let(:event) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_ADDED }
let(:namespace) { project.namespace }
subject(:service_action) { execute_create_service }
end
diff --git a/spec/services/notes/destroy_service_spec.rb b/spec/services/notes/destroy_service_spec.rb
index 54782774b4e..33c973a2431 100644
--- a/spec/services/notes/destroy_service_spec.rb
+++ b/spec/services/notes/destroy_service_spec.rb
@@ -26,7 +26,7 @@ RSpec.describe Notes::DestroyService, feature_category: :team_planning do
end
describe 'comment removed event tracking', :snowplow do
- let(:action) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_REMOVED }
+ let(:event) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_REMOVED }
let(:note) { create(:note, project: project, noteable: issue) }
let(:service_action) { described_class.new(project, user).execute(note) }
@@ -39,7 +39,7 @@ RSpec.describe Notes::DestroyService, feature_category: :team_planning do
expect do
service_action
end.to change {
- counter.unique_events(event_names: action, start_date: Date.today.beginning_of_week, end_date: 1.week.from_now)
+ counter.unique_events(event_names: event, start_date: Date.today.beginning_of_week, end_date: 1.week.from_now)
}.by(1)
end
diff --git a/spec/services/notes/quick_actions_service_spec.rb b/spec/services/notes/quick_actions_service_spec.rb
index b6e29299fdd..0a16037c976 100644
--- a/spec/services/notes/quick_actions_service_spec.rb
+++ b/spec/services/notes/quick_actions_service_spec.rb
@@ -334,6 +334,85 @@ RSpec.describe Notes::QuickActionsService, feature_category: :team_planning do
end
end
+ describe '/add_child' do
+ let_it_be_with_reload(:noteable) { create(:work_item, :objective, project: project) }
+ let_it_be_with_reload(:child) { create(:work_item, :objective, project: project) }
+ let_it_be_with_reload(:second_child) { create(:work_item, :objective, project: project) }
+ let_it_be(:note_text) { "/add_child #{child.to_reference}, #{second_child.to_reference}" }
+ let_it_be(:note) { create(:note, noteable: noteable, project: project, note: note_text) }
+ let_it_be(:children) { [child, second_child] }
+
+ shared_examples 'adds child work items' do
+ it 'leaves the note empty' do
+ expect(execute(note)).to be_empty
+ end
+
+ it 'adds child work items' do
+ execute(note)
+
+ expect(noteable.valid?).to be_truthy
+ expect(noteable.work_item_children).to eq(children)
+ end
+ end
+
+ context 'when using work item reference' do
+ let_it_be(:note_text) { "/add_child #{child.to_reference(full: true)},#{second_child.to_reference(full: true)}" }
+
+ it_behaves_like 'adds child work items'
+ end
+
+ context 'when using work item iid' do
+ it_behaves_like 'adds child work items'
+ end
+
+ context 'when using work item URL' do
+ let_it_be(:project_path) { "#{Gitlab.config.gitlab.url}/#{project.full_path}" }
+ let_it_be(:url) { "#{project_path}/work_items/#{child.iid},#{project_path}/work_items/#{second_child.iid}" }
+ let_it_be(:note_text) { "/add_child #{url}" }
+
+ it_behaves_like 'adds child work items'
+ end
+ end
+
+ describe '/set_parent' do
+ let_it_be_with_reload(:noteable) { create(:work_item, :objective, project: project) }
+ let_it_be_with_reload(:parent) { create(:work_item, :objective, project: project) }
+ let_it_be(:note_text) { "/set_parent #{parent.to_reference}" }
+ let_it_be(:note) { create(:note, noteable: noteable, project: project, note: note_text) }
+
+ shared_examples 'sets work item parent' do
+ it 'leaves the note empty' do
+ expect(execute(note)).to be_empty
+ end
+
+ it 'sets work item parent' do
+ execute(note)
+
+ expect(parent.valid?).to be_truthy
+ expect(noteable.work_item_parent).to eq(parent)
+ end
+ end
+
+ context 'when using work item reference' do
+ let_it_be(:note_text) { "/set_parent #{project.full_path}#{parent.to_reference}" }
+
+ it_behaves_like 'sets work item parent'
+ end
+
+ context 'when using work item iid' do
+ let_it_be(:note_text) { "/set_parent #{parent.to_reference}" }
+
+ it_behaves_like 'sets work item parent'
+ end
+
+ context 'when using work item URL' do
+ let_it_be(:url) { "#{Gitlab.config.gitlab.url}/#{project.full_path}/work_items/#{parent.iid}" }
+ let_it_be(:note_text) { "/set_parent #{url}" }
+
+ it_behaves_like 'sets work item parent'
+ end
+ end
+
describe '/promote_to' do
shared_examples 'promotes work item' do |from:, to:|
it 'leaves the note empty' do
diff --git a/spec/services/notes/update_service_spec.rb b/spec/services/notes/update_service_spec.rb
index 8389db000b8..908f348c68b 100644
--- a/spec/services/notes/update_service_spec.rb
+++ b/spec/services/notes/update_service_spec.rb
@@ -76,7 +76,7 @@ RSpec.describe Notes::UpdateService, feature_category: :team_planning do
end
it_behaves_like 'internal event tracking' do
- let(:action) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_EDITED }
+ let(:event) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_EDITED }
let(:namespace) { project.namespace }
subject(:service_action) { update_note(note: 'new text') }