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/lib/gitlab/tree_summary_spec.rb')
-rw-r--r--spec/lib/gitlab/tree_summary_spec.rb27
1 files changed, 20 insertions, 7 deletions
diff --git a/spec/lib/gitlab/tree_summary_spec.rb b/spec/lib/gitlab/tree_summary_spec.rb
index 593b8655e80..4bd08fab60a 100644
--- a/spec/lib/gitlab/tree_summary_spec.rb
+++ b/spec/lib/gitlab/tree_summary_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe Gitlab::TreeSummary do
+RSpec.describe Gitlab::TreeSummary do
using RSpec::Parameterized::TableSyntax
let(:project) { create(:project, :empty_repo) }
@@ -47,15 +47,17 @@ describe Gitlab::TreeSummary do
end
describe '#summarize (entries)' do
- let(:limit) { 2 }
+ let(:limit) { 4 }
custom_files = {
'a.txt' => '',
'b.txt' => '',
- 'directory/c.txt' => ''
+ 'directory/c.txt' => '',
+ ':dir/test.txt' => '',
+ ':file' => ''
}
- let(:project) { create(:project, :custom_repo, files: custom_files) }
+ let!(:project) { create(:project, :custom_repo, files: custom_files) }
let(:commit) { repo.head_commit }
subject(:entries) { summary.summarize.first }
@@ -63,13 +65,16 @@ describe Gitlab::TreeSummary do
it 'summarizes the entries within the window' do
is_expected.to contain_exactly(
a_hash_including(type: :tree, file_name: 'directory'),
- a_hash_including(type: :blob, file_name: 'a.txt')
+ a_hash_including(type: :blob, file_name: 'a.txt'),
+ a_hash_including(type: :blob, file_name: ':file'),
+ a_hash_including(type: :tree, file_name: ':dir')
# b.txt is excluded by the limit
)
end
it 'references the commit and commit path in entries' do
- entry = entries.first
+ # There are 2 trees and the summary is not ordered
+ entry = entries.find { |entry| entry[:commit].id == commit.id }
expected_commit_path = Gitlab::Routing.url_helpers.project_commit_path(project, commit)
expect(entry[:commit]).to be_a(::Commit)
@@ -85,6 +90,14 @@ describe Gitlab::TreeSummary do
end
end
+ context 'in a subdirectory with a pathspec character' do
+ let(:path) { ':dir' }
+
+ it 'summarizes the entries in the subdirectory' do
+ is_expected.to contain_exactly(a_hash_including(type: :blob, file_name: 'test.txt'))
+ end
+ end
+
context 'in a non-existent subdirectory' do
let(:path) { 'tmp' }
@@ -92,7 +105,7 @@ describe Gitlab::TreeSummary do
end
context 'custom offset and limit' do
- let(:offset) { 2 }
+ let(:offset) { 4 }
it 'returns entries from the offset' do
is_expected.to contain_exactly(a_hash_including(type: :blob, file_name: 'b.txt'))