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-08-18 13:50:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-08-18 13:50:51 +0300
commitdb384e6b19af03b4c3c82a5760d83a3fd79f7982 (patch)
tree34beaef37df5f47ccbcf5729d7583aae093cffa0 /spec/services/suggestions
parent54fd7b1bad233e3944434da91d257fa7f63c3996 (diff)
Add latest changes from gitlab-org/gitlab@16-3-stable-eev16.3.0-rc42
Diffstat (limited to 'spec/services/suggestions')
-rw-r--r--spec/services/suggestions/apply_service_spec.rb69
-rw-r--r--spec/services/suggestions/create_service_spec.rb51
-rw-r--r--spec/services/suggestions/outdate_service_spec.rb21
3 files changed, 85 insertions, 56 deletions
diff --git a/spec/services/suggestions/apply_service_spec.rb b/spec/services/suggestions/apply_service_spec.rb
index 6e2c623035e..c49c1fb54a7 100644
--- a/spec/services/suggestions/apply_service_spec.rb
+++ b/spec/services/suggestions/apply_service_spec.rb
@@ -22,10 +22,12 @@ RSpec.describe Suggestions::ApplyService, feature_category: :code_suggestions do
position = build_position(**position_args)
- diff_note = create(:diff_note_on_merge_request,
- noteable: merge_request,
- position: position,
- project: project)
+ diff_note = create(
+ :diff_note_on_merge_request,
+ noteable: merge_request,
+ position: position,
+ project: project
+ )
suggestion_args = { note: diff_note }.merge(content_args)
@@ -46,8 +48,7 @@ RSpec.describe Suggestions::ApplyService, feature_category: :code_suggestions do
suggestions.each do |suggestion|
path = suggestion.diff_file.file_path
- blob = project.repository.blob_at_branch(merge_request.source_branch,
- path)
+ blob = project.repository.blob_at_branch(merge_request.source_branch, path)
expect(blob.data).to eq(expected_content_by_path[path.to_sym])
end
@@ -398,9 +399,11 @@ RSpec.describe Suggestions::ApplyService, feature_category: :code_suggestions do
expect(result[:status]).to eq(:success)
refresh = MergeRequests::RefreshService.new(project: project, current_user: user)
- refresh.execute(merge_request.diff_head_sha,
- suggestion.commit_id,
- merge_request.source_branch_ref)
+ refresh.execute(
+ merge_request.diff_head_sha,
+ suggestion.commit_id,
+ merge_request.source_branch_ref
+ )
result
end
@@ -576,18 +579,22 @@ RSpec.describe Suggestions::ApplyService, feature_category: :code_suggestions do
end
let(:merge_request) do
- create(:merge_request,
- source_branch: 'conflict-resolvable-fork',
- source_project: forked_project,
- target_branch: 'conflict-start',
- target_project: project)
+ create(
+ :merge_request,
+ source_branch: 'conflict-resolvable-fork',
+ source_project: forked_project,
+ target_branch: 'conflict-start',
+ target_project: project
+ )
end
let!(:diff_note) do
- create(:diff_note_on_merge_request,
- noteable: merge_request,
- position: position,
- project: project)
+ create(
+ :diff_note_on_merge_request,
+ noteable: merge_request,
+ position: position,
+ project: project
+ )
end
before do
@@ -596,9 +603,8 @@ RSpec.describe Suggestions::ApplyService, feature_category: :code_suggestions do
it 'updates file in the source project' do
expect(Files::MultiService).to receive(:new)
- .with(merge_request.source_project,
- user,
- anything).and_call_original
+ .with(merge_request.source_project, user, anything)
+ .and_call_original
apply_service.new(user, suggestion).execute
end
@@ -623,8 +629,10 @@ RSpec.describe Suggestions::ApplyService, feature_category: :code_suggestions do
it 'returns error' do
result = apply_service.new(user, suggestion).execute
- expect(result).to eq(message: "You are not allowed to push into this branch",
- status: :error)
+ expect(result).to eq(
+ message: "You are not allowed to push into this branch",
+ status: :error
+ )
end
end
end
@@ -660,8 +668,7 @@ RSpec.describe Suggestions::ApplyService, feature_category: :code_suggestions do
end
it 'returns error message' do
- expect(result).to eq(message: 'A file was not found.',
- status: :error)
+ expect(result).to eq(message: 'A file was not found.', status: :error)
end
it_behaves_like 'service not tracking apply suggestion event'
@@ -700,8 +707,10 @@ RSpec.describe Suggestions::ApplyService, feature_category: :code_suggestions do
let(:result) { apply_service.new(user, suggestion, other_branch_suggestion).execute }
it 'renders error message' do
- expect(result).to eq(message: 'Suggestions must all be on the same branch.',
- status: :error)
+ expect(result).to eq(
+ message: 'Suggestions must all be on the same branch.',
+ status: :error
+ )
end
it_behaves_like 'service not tracking apply suggestion event'
@@ -736,8 +745,10 @@ RSpec.describe Suggestions::ApplyService, feature_category: :code_suggestions do
let(:result) { apply_service.new(user, suggestion, overlapping_suggestion).execute }
it 'returns error message' do
- expect(result).to eq(message: 'Suggestions are not applicable as their lines cannot overlap.',
- status: :error)
+ expect(result).to eq(
+ message: 'Suggestions are not applicable as their lines cannot overlap.',
+ status: :error
+ )
end
it_behaves_like 'service not tracking apply suggestion event'
diff --git a/spec/services/suggestions/create_service_spec.rb b/spec/services/suggestions/create_service_spec.rb
index a8bc3cba697..483022ea46e 100644
--- a/spec/services/suggestions/create_service_spec.rb
+++ b/spec/services/suggestions/create_service_spec.rb
@@ -5,8 +5,11 @@ require 'spec_helper'
RSpec.describe Suggestions::CreateService, feature_category: :code_suggestions do
let(:project_with_repo) { create(:project, :repository) }
let(:merge_request) do
- create(:merge_request, source_project: project_with_repo,
- target_project: project_with_repo)
+ create(
+ :merge_request,
+ source_project: project_with_repo,
+ target_project: project_with_repo
+ )
end
def build_position(args = {})
@@ -66,8 +69,7 @@ RSpec.describe Suggestions::CreateService, feature_category: :code_suggestions d
context 'should not try to parse suggestions' do
context 'when not a diff note for merge requests' do
let(:note) do
- create(:diff_note_on_commit, project: project_with_repo,
- note: markdown)
+ create(:diff_note_on_commit, project: project_with_repo, note: markdown)
end
it 'does not try to parse suggestions' do
@@ -81,10 +83,13 @@ RSpec.describe Suggestions::CreateService, feature_category: :code_suggestions d
context 'when diff note is not for text' do
let(:note) do
- create(:diff_note_on_merge_request, project: project_with_repo,
- noteable: merge_request,
- position: position,
- note: markdown)
+ create(
+ :diff_note_on_merge_request,
+ project: project_with_repo,
+ noteable: merge_request,
+ position: position,
+ note: markdown
+ )
end
before do
@@ -103,10 +108,13 @@ RSpec.describe Suggestions::CreateService, feature_category: :code_suggestions d
context 'when diff file is not found' do
let(:note) do
- create(:diff_note_on_merge_request, project: project_with_repo,
- noteable: merge_request,
- position: position,
- note: markdown)
+ create(
+ :diff_note_on_merge_request,
+ project: project_with_repo,
+ noteable: merge_request,
+ position: position,
+ note: markdown
+ )
end
before do
@@ -124,16 +132,21 @@ RSpec.describe Suggestions::CreateService, feature_category: :code_suggestions d
context 'should create suggestions' do
let(:note) do
- create(:diff_note_on_merge_request, project: project_with_repo,
- noteable: merge_request,
- position: position,
- note: markdown)
+ create(
+ :diff_note_on_merge_request,
+ project: project_with_repo,
+ noteable: merge_request,
+ position: position,
+ note: markdown
+ )
end
let(:expected_suggestions) do
- Gitlab::Diff::SuggestionsParser.parse(markdown,
- project: note.project,
- position: note.position)
+ Gitlab::Diff::SuggestionsParser.parse(
+ markdown,
+ project: note.project,
+ position: note.position
+ )
end
it 'persists suggestion records' do
diff --git a/spec/services/suggestions/outdate_service_spec.rb b/spec/services/suggestions/outdate_service_spec.rb
index 7bd70866bf7..20209097394 100644
--- a/spec/services/suggestions/outdate_service_spec.rb
+++ b/spec/services/suggestions/outdate_service_spec.rb
@@ -12,17 +12,22 @@ RSpec.describe Suggestions::OutdateService, feature_category: :code_suggestions
let(:diff_file) { suggestion.diff_file }
let(:position) { build_position(file_path, comment_line) }
let(:note) do
- create(:diff_note_on_merge_request, noteable: merge_request,
- position: position,
- project: project)
+ create(
+ :diff_note_on_merge_request,
+ noteable: merge_request,
+ position: position,
+ project: project
+ )
end
def build_position(path, line)
- Gitlab::Diff::Position.new(old_path: path,
- new_path: path,
- old_line: nil,
- new_line: line,
- diff_refs: merge_request.diff_refs)
+ Gitlab::Diff::Position.new(
+ old_path: path,
+ new_path: path,
+ old_line: nil,
+ new_line: line,
+ diff_refs: merge_request.diff_refs
+ )
end
def commit_changes(file_path, new_content)