diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-03 21:06:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-03 21:06:11 +0300 |
commit | 25521def84a6987fe9d4265b560e930bfb32c195 (patch) | |
tree | 711e001ea65f76a9c2eb034c4531bda325af84f3 /spec/graphql/resolvers | |
parent | 9a1c5456747a7b5b218b8b44e4b43396bf7fd705 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql/resolvers')
-rw-r--r-- | spec/graphql/resolvers/last_commit_resolver_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/graphql/resolvers/last_commit_resolver_spec.rb b/spec/graphql/resolvers/last_commit_resolver_spec.rb new file mode 100644 index 00000000000..15b09b77a10 --- /dev/null +++ b/spec/graphql/resolvers/last_commit_resolver_spec.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Resolvers::LastCommitResolver do + include GraphqlHelpers + + let(:repository) { create(:project, :repository).repository } + let(:tree) { repository.tree(ref, path) } + + let(:commit) { resolve(described_class, obj: tree) } + + describe '#resolve' do + context 'last commit is a merge commit' do + let(:ref) { 'master' } + let(:path) { '/' } + + it 'resolves to the merge commit' do + expect(commit).to eq(repository.commits(ref, limit: 1).last) + end + end + + context 'last commit for a different branch and path' do + let(:ref) { 'fix' } + let(:path) { 'files' } + + it 'resolves commit' do + expect(commit).to eq(repository.commits(ref, path: path, limit: 1).last) + end + end + + context 'last commit does not exist' do + let(:ref) { 'master' } + let(:path) { 'does-not-exist' } + + it 'returns nil' do + expect(commit).to be_nil + end + end + end +end |