summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-01-20 14:51:56 +0100
committerDouwe Maan <douwe@gitlab.com>2016-01-20 14:53:20 +0100
commit701513dcc7afb403372bc738642a9a52e9be5983 (patch)
treef2eb3cf87de08bbfdfb22d67de7112616b766426 /spec
parentc7264d2a76abdc9d173e2160e27974d41380e93f (diff)
downloadgitlab-ce-701513dcc7afb403372bc738642a9a52e9be5983.tar.gz
Move parallel diff logic to separate class
Diffstat (limited to 'spec')
-rw-r--r--spec/helpers/diff_helper_spec.rb18
-rw-r--r--spec/lib/gitlab/diff/parallel_diff_spec.rb22
2 files changed, 22 insertions, 18 deletions
diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb
index 435ecd04fbe..955d2852cfd 100644
--- a/spec/helpers/diff_helper_spec.rb
+++ b/spec/helpers/diff_helper_spec.rb
@@ -84,20 +84,6 @@ describe DiffHelper do
end
end
- describe 'parallel_diff' do
- it 'should return an array of arrays containing the parsed diff' do
- expect(parallel_diff(diff_file, 0)).
- to match_array(parallel_diff_result_array)
- end
- end
-
- describe 'generate_line_code' do
- it 'should generate correct line code' do
- expect(generate_line_code(diff_file.file_path, diff_file.diff_lines.first)).
- to eq('2f6fcd96b88b36ce98c38da085c795a27d92a3dd_6_6')
- end
- end
-
describe 'unfold_bottom_class' do
it 'should return empty string when bottom line shouldnt be unfolded' do
expect(unfold_bottom_class(false)).to eq('')
@@ -135,8 +121,4 @@ describe DiffHelper do
expect(diff_line_content(diff_file.diff_lines.first.text)).to be_html_safe
end
end
-
- def parallel_diff_result_array
- YAML.load_file("#{Rails.root}/spec/fixtures/parallel_diff_result.yml")
- end
end
diff --git a/spec/lib/gitlab/diff/parallel_diff_spec.rb b/spec/lib/gitlab/diff/parallel_diff_spec.rb
new file mode 100644
index 00000000000..852218b4e62
--- /dev/null
+++ b/spec/lib/gitlab/diff/parallel_diff_spec.rb
@@ -0,0 +1,22 @@
+require 'spec_helper'
+
+describe Gitlab::Diff::ParallelDiff, lib: true do
+ include RepoHelpers
+
+ let(:project) { create(:project) }
+ let(:repository) { project.repository }
+ let(:commit) { project.commit(sample_commit.id) }
+ let(:diffs) { commit.diffs }
+ let(:diff) { diffs.first }
+ let(:diff_refs) { [commit.parent, commit] }
+ let(:diff_file) { Gitlab::Diff::File.new(diff, diff_refs) }
+ subject { described_class.new(diff_file) }
+
+ let(:parallel_diff_result_array) { YAML.load_file("#{Rails.root}/spec/fixtures/parallel_diff_result.yml") }
+
+ describe '#parallelize' do
+ it 'should return an array of arrays containing the parsed diff' do
+ expect(subject.parallelize).to match_array(parallel_diff_result_array)
+ end
+ end
+end