diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/lib/gitlab/tree_summary_spec.rb | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/lib/gitlab/tree_summary_spec.rb')
-rw-r--r-- | spec/lib/gitlab/tree_summary_spec.rb | 27 |
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')) |