diff options
Diffstat (limited to 'spec/services/notes')
-rw-r--r-- | spec/services/notes/create_service_spec.rb | 5 | ||||
-rw-r--r-- | spec/services/notes/destroy_service_spec.rb | 7 | ||||
-rw-r--r-- | spec/services/notes/quick_actions_service_spec.rb | 39 | ||||
-rw-r--r-- | spec/services/notes/update_service_spec.rb | 12 |
4 files changed, 53 insertions, 10 deletions
diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb index 22509885c92..b5eb5f8037a 100644 --- a/spec/services/notes/create_service_spec.rb +++ b/spec/services/notes/create_service_spec.rb @@ -180,8 +180,9 @@ RSpec.describe Notes::CreateService, feature_category: :team_planning do execute_create_service end - it_behaves_like 'issue_edit snowplow tracking' do - let(:property) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_ADDED } + it_behaves_like 'internal event tracking' do + let(:action) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_ADDED } + let(:namespace) { project.namespace } subject(:service_action) { execute_create_service } end end diff --git a/spec/services/notes/destroy_service_spec.rb b/spec/services/notes/destroy_service_spec.rb index 396e23351c9..54782774b4e 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(:property) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_REMOVED } + let(:action) { 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,11 +39,12 @@ RSpec.describe Notes::DestroyService, feature_category: :team_planning do expect do service_action end.to change { - counter.unique_events(event_names: property, start_date: Date.today.beginning_of_week, end_date: 1.week.from_now) + counter.unique_events(event_names: action, start_date: Date.today.beginning_of_week, end_date: 1.week.from_now) }.by(1) end - it_behaves_like 'issue_edit snowplow tracking' do + it_behaves_like 'internal event tracking' do + let(:namespace) { project.namespace } subject(:execute_service_action) { service_action } end end diff --git a/spec/services/notes/quick_actions_service_spec.rb b/spec/services/notes/quick_actions_service_spec.rb index 0065fd639b8..b6e29299fdd 100644 --- a/spec/services/notes/quick_actions_service_spec.rb +++ b/spec/services/notes/quick_actions_service_spec.rb @@ -188,6 +188,45 @@ RSpec.describe Notes::QuickActionsService, feature_category: :team_planning do end end + describe '/confidential' do + let_it_be_with_reload(:noteable) { create(:work_item, :issue, project: project) } + let_it_be(:note_text) { '/confidential' } + let_it_be(:note) { create(:note, noteable: noteable, project: project, note: note_text) } + + context 'when work item does not have children' do + it 'leaves the note empty' do + expect(execute(note)).to be_empty + end + + it 'marks work item as confidential' do + expect { execute(note) }.to change { noteable.reload.confidential }.from(false).to(true) + end + end + + context 'when work item has children' do + before do + create(:parent_link, work_item: task, work_item_parent: noteable) + end + + context 'when children are not confidential' do + let(:task) { create(:work_item, :task, project: project) } + + it 'does not mark parent work item as confidential' do + expect { execute(note) }.to not_change { noteable.reload.confidential }.from(false) + expect(noteable.errors[:base]).to include('A confidential work item cannot have a parent that already has non-confidential children.') + end + end + + context 'when children are confidential' do + let(:task) { create(:work_item, :confidential, :task, project: project) } + + it 'marks parent work item as confidential' do + expect { execute(note) }.to change { noteable.reload.confidential }.from(false).to(true) + end + end + end + end + describe 'note with command & text' do describe '/close, /label, /assign & /milestone' do let(:note_text) do diff --git a/spec/services/notes/update_service_spec.rb b/spec/services/notes/update_service_spec.rb index e109bfbcd0b..8389db000b8 100644 --- a/spec/services/notes/update_service_spec.rb +++ b/spec/services/notes/update_service_spec.rb @@ -75,6 +75,13 @@ RSpec.describe Notes::UpdateService, feature_category: :team_planning do update_note({}) end + it_behaves_like 'internal event tracking' do + let(:action) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_EDITED } + let(:namespace) { project.namespace } + + subject(:service_action) { update_note(note: 'new text') } + end + it 'tracks issue usage data', :clean_gitlab_redis_shared_state do counter = Gitlab::UsageDataCounters::HLLRedisCounter @@ -85,11 +92,6 @@ RSpec.describe Notes::UpdateService, feature_category: :team_planning do update_note(note: 'new text') end.to change { counter.unique_events(event_names: event, start_date: Date.today.beginning_of_week, end_date: 1.week.from_now) }.by(1) end - - it_behaves_like 'issue_edit snowplow tracking' do - let(:property) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_EDITED } - subject(:service_action) { update_note(note: 'new text') } - end end context 'when note text was changed' do |