summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-04-17 15:19:53 +0000
committerDouwe Maan <douwe@gitlab.com>2017-04-17 15:19:53 +0000
commit41acc87fbd457d2894fb519eb48f215d017ddec2 (patch)
tree2a9d37a1d41b0632831d76290317b35b213b1ba0
parent0567f076c4620e3c22efa9436091708c16ba1586 (diff)
parent2545f6adbfb6977a2d677805b3b04256103573ca (diff)
downloadgitlab-ce-41acc87fbd457d2894fb519eb48f215d017ddec2.tar.gz
Merge branch 'fix-follow-with-multiple-paths' into 'master'
Fix following with multiple paths Closes gitlab-ee#2175 See merge request !10737
-rw-r--r--app/models/repository.rb2
-rw-r--r--spec/models/repository_spec.rb21
2 files changed, 22 insertions, 1 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 1d6acbda235..7bb874d7744 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -108,7 +108,7 @@ class Repository
offset: offset,
after: after,
before: before,
- follow: path.present?,
+ follow: Array(path).length == 1,
skip_merges: skip_merges
}
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 5f8337220df..74d5ebc6db0 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -171,6 +171,27 @@ describe Repository, models: true do
end
end
+ describe '#commits' do
+ it 'sets follow when path is a single path' do
+ expect(Gitlab::Git::Commit).to receive(:where).with(a_hash_including(follow: true)).and_call_original.twice
+
+ repository.commits('master', path: 'README.md')
+ repository.commits('master', path: ['README.md'])
+ end
+
+ it 'does not set follow when path is multiple paths' do
+ expect(Gitlab::Git::Commit).to receive(:where).with(a_hash_including(follow: false)).and_call_original
+
+ repository.commits('master', path: ['README.md', 'CHANGELOG'])
+ end
+
+ it 'does not set follow when there are no paths' do
+ expect(Gitlab::Git::Commit).to receive(:where).with(a_hash_including(follow: false)).and_call_original
+
+ repository.commits('master')
+ end
+ end
+
describe '#find_commits_by_message' do
it 'returns commits with messages containing a given string' do
commit_ids = repository.find_commits_by_message('submodule').map(&:id)