Commit 948ac8b9 authored by nmilojevic1's avatar nmilojevic1

Fix Lint errors

  Add localization in gitlab.pot
  Fix various lint errors and messages
parent 53ee65fc
......@@ -39,13 +39,16 @@ class DiffNote < Note
return unless should_create_diff_file?
diff_file = fetch_diff_file
raise NoteDiffFileCreationError, DIFF_FILE_NOT_FOUND_MESSAGE unless diff_file
raise NoteDiffFileCreationError, DIFF_FILE_NOT_FOUND_MESSAGE unless diff_file
diff_line = diff_file.line_for_position(self.original_position)
raise NoteDiffFileCreationError, DIFF_LINE_NOT_FOUND_MESSAGE % {
file_path: diff_file.file_path,
new_pos: original_position.new_line,
old_pos: original_position.old_line
} unless diff_line
unless diff_line
raise NoteDiffFileCreationError, DIFF_LINE_NOT_FOUND_MESSAGE % {
file_path: diff_file.file_path,
new_pos: original_position.new_line,
old_pos: original_position.old_line
}
end
creation_params = diff_file.diff.to_hash
.except(:too_large)
......@@ -121,6 +124,7 @@ class DiffNote < Note
def fetch_diff_file
return note_diff_file.raw_diff_file if note_diff_file
if created_at_diff?(noteable.diff_refs)
# We're able to use the already persisted diffs (Postgres) if we're
# presenting a "current version" of the MR discussion diff.
......@@ -132,6 +136,7 @@ class DiffNote < Note
# if line is not found in persisted diffs, fallback and retrieve file from repository using gitaly
file = nil if file&.line_for_position(original_position).nil? && importing?
end
file ||= original_position.diff_file(repository)
file&.unfold_diff_lines(position)
......
......@@ -7373,6 +7373,12 @@ msgstr ""
msgid "Failed to enqueue the rebase operation, possibly due to a long-lived transaction. Try again later."
msgstr ""
msgid "Failed to find diff file"
msgstr ""
msgid "Failed to find diff line for: %{file_path}, new_pos: %{new_pos}, old_pos: %{old_pos}"
msgstr ""
msgid "Failed to get ref."
msgstr ""
......
......@@ -91,7 +91,6 @@ describe DiffNote do
end
describe '#create_diff_file callback' do
context 'merge request' do
let(:position) do
Gitlab::Diff::Position.new(old_path: "files/ruby/popen.rb",
......@@ -101,6 +100,7 @@ describe DiffNote do
diff_refs: merge_request.diff_refs)
end
subject { build(:diff_note_on_merge_request, project: project, position: position, noteable: merge_request) }
let(:diff_file_from_repository) do
position.diff_file(project.repository)
end
......@@ -168,7 +168,6 @@ describe DiffNote do
subject.save
expect(subject.reload.note_diff_file).to be_present
end
end
end
end
......@@ -189,7 +188,7 @@ describe DiffNote do
end
it 'does not create diff note file if it is a reply' do
diff_note = create(:diff_note_on_merge_request, project: project, noteable: merge_request)
diff_note = create(:diff_note_on_merge_request, project: project, noteable: merge_request)
expect { create(:diff_note_on_merge_request, noteable: merge_request, in_reply_to: diff_note) }
.not_to change(NoteDiffFile, :count)
end
......
# frozen_string_literal: true
shared_examples 'a valid diff note with after commit callback' do
context 'when diff file is fetched from repository' do
before do
allow_any_instance_of(::Gitlab::Diff::Position).to receive(:diff_file).with(project.repository).and_return(diff_file_from_repository)
......@@ -31,7 +30,6 @@ shared_examples 'a valid diff note with after commit callback' do
subject.save
expect(subject.reload.note_diff_file).to be_present
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment