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/create_service_spec.rb')
-rw-r--r--spec/services/notes/create_service_spec.rb141
1 files changed, 86 insertions, 55 deletions
diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb
index 1ee9e51433e..240d81bb485 100644
--- a/spec/services/notes/create_service_spec.rb
+++ b/spec/services/notes/create_service_spec.rb
@@ -108,7 +108,6 @@ RSpec.describe Notes::CreateService, feature_category: :team_planning do
end
it_behaves_like 'Snowplow event tracking with RedisHLL context' do
- let(:feature_flag_name) { :route_hll_to_snowplow_phase2 }
let(:namespace) { issue.namespace }
let(:category) { described_class.to_s }
let(:action) { 'incident_management_incident_comment' }
@@ -124,10 +123,6 @@ RSpec.describe Notes::CreateService, feature_category: :team_planning do
let(:execute_create_service) { described_class.new(project, user, opts).execute }
- before do
- stub_feature_flags(notes_create_service_tracking: false)
- end
-
it 'tracks commit comment usage data', :clean_gitlab_redis_shared_state do
expect(counter).to receive(:count).with(:create, 'Commit').and_call_original
@@ -141,7 +136,6 @@ RSpec.describe Notes::CreateService, feature_category: :team_planning do
let(:action) { 'create_commit_comment' }
let(:label) { 'counts.commit_comment' }
let(:namespace) { project.namespace }
- let(:feature_flag_name) { :route_hll_to_snowplow_phase4 }
end
end
@@ -157,7 +151,9 @@ RSpec.describe Notes::CreateService, feature_category: :team_planning do
.and_call_original
expect do
execute_create_service
- end.to change { counter.unique_events(event_names: event, start_date: 1.day.ago, end_date: 1.day.from_now) }.by(1)
+ 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 'does not track merge request usage data' do
@@ -178,22 +174,45 @@ RSpec.describe Notes::CreateService, feature_category: :team_planning do
create(:merge_request, source_project: project_with_repo, target_project: project_with_repo)
end
+ let(:new_opts) { opts.merge(noteable_type: 'MergeRequest', noteable_id: merge_request.id) }
+
+ it 'calls MergeRequests::MarkReviewerReviewedService service' do
+ expect_next_instance_of(
+ MergeRequests::MarkReviewerReviewedService,
+ project: project_with_repo, current_user: user
+ ) do |service|
+ expect(service).to receive(:execute).with(merge_request)
+ end
+
+ described_class.new(project_with_repo, user, new_opts).execute
+ end
+
+ it 'does not call MergeRequests::MarkReviewerReviewedService service when skip_set_reviewed is true' do
+ expect(MergeRequests::MarkReviewerReviewedService).not_to receive(:new)
+
+ described_class.new(project_with_repo, user, new_opts).execute(skip_set_reviewed: true)
+ end
+
context 'noteable highlight cache clearing' do
let(:position) do
- Gitlab::Diff::Position.new(old_path: "files/ruby/popen.rb",
- new_path: "files/ruby/popen.rb",
- old_line: nil,
- new_line: 14,
- diff_refs: merge_request.diff_refs)
+ Gitlab::Diff::Position.new(
+ old_path: "files/ruby/popen.rb",
+ new_path: "files/ruby/popen.rb",
+ old_line: nil,
+ new_line: 14,
+ diff_refs: merge_request.diff_refs
+ )
end
let(:new_opts) do
- opts.merge(in_reply_to_discussion_id: nil,
- type: 'DiffNote',
- noteable_type: 'MergeRequest',
- noteable_id: merge_request.id,
- position: position.to_h,
- confidential: false)
+ opts.merge(
+ in_reply_to_discussion_id: nil,
+ type: 'DiffNote',
+ noteable_type: 'MergeRequest',
+ noteable_id: merge_request.id,
+ position: position.to_h,
+ confidential: false
+ )
end
before do
@@ -223,12 +242,14 @@ RSpec.describe Notes::CreateService, feature_category: :team_planning do
prev_note =
create(:diff_note_on_merge_request, noteable: merge_request, project: project_with_repo)
reply_opts =
- opts.merge(in_reply_to_discussion_id: prev_note.discussion_id,
- type: 'DiffNote',
- noteable_type: 'MergeRequest',
- noteable_id: merge_request.id,
- position: position.to_h,
- confidential: false)
+ opts.merge(
+ in_reply_to_discussion_id: prev_note.discussion_id,
+ type: 'DiffNote',
+ noteable_type: 'MergeRequest',
+ noteable_id: merge_request.id,
+ position: position.to_h,
+ confidential: false
+ )
expect(merge_request).not_to receive(:diffs)
@@ -239,11 +260,13 @@ RSpec.describe Notes::CreateService, feature_category: :team_planning do
context 'note diff file' do
let(:line_number) { 14 }
let(:position) do
- Gitlab::Diff::Position.new(old_path: "files/ruby/popen.rb",
- new_path: "files/ruby/popen.rb",
- old_line: nil,
- new_line: line_number,
- diff_refs: merge_request.diff_refs)
+ Gitlab::Diff::Position.new(
+ old_path: "files/ruby/popen.rb",
+ new_path: "files/ruby/popen.rb",
+ old_line: nil,
+ new_line: line_number,
+ diff_refs: merge_request.diff_refs
+ )
end
let(:previous_note) do
@@ -255,12 +278,14 @@ RSpec.describe Notes::CreateService, feature_category: :team_planning do
end
context 'when eligible to have a note diff file' do
let(:new_opts) do
- opts.merge(in_reply_to_discussion_id: nil,
- type: 'DiffNote',
- noteable_type: 'MergeRequest',
- noteable_id: merge_request.id,
- position: position.to_h,
- confidential: false)
+ opts.merge(
+ in_reply_to_discussion_id: nil,
+ type: 'DiffNote',
+ noteable_type: 'MergeRequest',
+ noteable_id: merge_request.id,
+ position: position.to_h,
+ confidential: false
+ )
end
it_behaves_like 'triggers GraphQL subscription mergeRequestMergeStatusUpdated' do
@@ -331,12 +356,14 @@ RSpec.describe Notes::CreateService, feature_category: :team_planning do
context 'when DiffNote is a reply' do
let(:new_opts) do
- opts.merge(in_reply_to_discussion_id: previous_note.discussion_id,
- type: 'DiffNote',
- noteable_type: 'MergeRequest',
- noteable_id: merge_request.id,
- position: position.to_h,
- confidential: false)
+ opts.merge(
+ in_reply_to_discussion_id: previous_note.discussion_id,
+ type: 'DiffNote',
+ noteable_type: 'MergeRequest',
+ noteable_id: merge_request.id,
+ position: position.to_h,
+ confidential: false
+ )
end
it 'note is not associated with a note diff file' do
@@ -350,23 +377,27 @@ RSpec.describe Notes::CreateService, feature_category: :team_planning do
context 'when DiffNote from an image' do
let(:image_position) do
- Gitlab::Diff::Position.new(old_path: "files/images/6049019_460s.jpg",
- new_path: "files/images/6049019_460s.jpg",
- width: 100,
- height: 100,
- x: 1,
- y: 100,
- diff_refs: merge_request.diff_refs,
- position_type: 'image')
+ Gitlab::Diff::Position.new(
+ old_path: "files/images/6049019_460s.jpg",
+ new_path: "files/images/6049019_460s.jpg",
+ width: 100,
+ height: 100,
+ x: 1,
+ y: 100,
+ diff_refs: merge_request.diff_refs,
+ position_type: 'image'
+ )
end
let(:new_opts) do
- opts.merge(in_reply_to_discussion_id: nil,
- type: 'DiffNote',
- noteable_type: 'MergeRequest',
- noteable_id: merge_request.id,
- position: image_position.to_h,
- confidential: false)
+ opts.merge(
+ in_reply_to_discussion_id: nil,
+ type: 'DiffNote',
+ noteable_type: 'MergeRequest',
+ noteable_id: merge_request.id,
+ position: image_position.to_h,
+ confidential: false
+ )
end
it 'note is not associated with a note diff file' do