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/helpers/diff_helper_spec.rb')
-rw-r--r--spec/helpers/diff_helper_spec.rb58
1 files changed, 58 insertions, 0 deletions
diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb
index ef1f0940074..c085c3bdbd9 100644
--- a/spec/helpers/diff_helper_spec.rb
+++ b/spec/helpers/diff_helper_spec.rb
@@ -130,6 +130,38 @@ RSpec.describe DiffHelper do
end
end
+ describe "#diff_link_number" do
+ using RSpec::Parameterized::TableSyntax
+
+ let(:line) do
+ double(:line, type: line_type)
+ end
+
+ # This helper is used to generate the line numbers on the
+ # diff lines. It essentially just returns a blank string
+ # on the old/new lines. The following table tests all the
+ # possible permutations for clarity.
+
+ where(:line_type, :match, :line_number, :expected_return_value) do
+ "new" | "new" | 1 | " "
+ "new" | "old" | 2 | 2
+ "old" | "new" | 3 | 3
+ "old" | "old" | 4 | " "
+ "new-nonewline" | "new" | 5 | 5
+ "new-nonewline" | "old" | 6 | 6
+ "old-nonewline" | "new" | 7 | 7
+ "old-nonewline" | "old" | 8 | 8
+ "match" | "new" | 9 | 9
+ "match" | "old" | 10 | 10
+ end
+
+ with_them do
+ it "returns the expected value" do
+ expect(helper.diff_link_number(line.type, match, line_number)).to eq(expected_return_value)
+ end
+ end
+ end
+
describe "#mark_inline_diffs" do
let(:old_line) { %{abc 'def'} }
let(:new_line) { %{abc "def"} }
@@ -326,4 +358,30 @@ RSpec.describe DiffHelper do
expect(diff_file_path_text(diff_file, max: 10)).to eq("...open.rb")
end
end
+
+ describe 'unified_diff_lines_view_type' do
+ before do
+ controller.params[:view] = 'parallel'
+ end
+
+ describe 'unified diffs enabled' do
+ before do
+ stub_feature_flags(unified_diff_lines: true)
+ end
+
+ it 'returns inline view' do
+ expect(helper.unified_diff_lines_view_type(project)).to eq 'inline'
+ end
+ end
+
+ describe 'unified diffs disabled' do
+ before do
+ stub_feature_flags(unified_diff_lines: false)
+ end
+
+ it 'returns parallel view' do
+ expect(helper.unified_diff_lines_view_type(project)).to eq :parallel
+ end
+ end
+ end
end