diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-03-24 15:35:49 +0100 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-03-24 15:38:16 +0100 |
commit | b105b84e3ac34915cf00b7bfec923abf98d035ab (patch) | |
tree | 8fd8eb0ccbf9bccd7351cf1a4ab9b4f29bf5c45c /spec/models | |
parent | 3b1543cd15fcc52c2f5f3b7f4ccf391334fb6028 (diff) | |
download | gitlab-ce-b105b84e3ac34915cf00b7bfec923abf98d035ab.tar.gz |
Use head tree (cached) for file search. Also add some tests
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/repository_spec.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 7eac70ae948..0ba9da29a97 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -148,6 +148,29 @@ describe Repository, models: true do end end + describe "#gitlab_ci_yml" do + before do + TestBlob = Struct.new(:name) + end + + it 'returns valid file' do + files = [TestBlob.new('file'), TestBlob.new('.gitlab-ci.yml'), TestBlob.new('copying')] + expect(repository.tree).to receive(:blobs).and_return(files) + + expect(repository.gitlab_ci_yml.name).to eq('.gitlab-ci.yml') + end + + it 'returns nil if not exists' do + expect(repository.tree).to receive(:blobs).and_return([]) + expect(repository.gitlab_ci_yml).to be_nil + end + + it 'returns nil for empty repository' do + expect(repository).to receive(:empty?).and_return(true) + expect(repository.gitlab_ci_yml).to be_nil + end + end + describe :add_branch do context 'when pre hooks were successful' do it 'should run without errors' do |