Commit afe86792 authored by Stan Hu's avatar Stan Hu

Rename branches_exist? -> includes_branches?

parent d96c24d8
......@@ -43,7 +43,7 @@ class PostReceive
return false unless user
# Expire the branches cache so we have updated data for this push
post_received.project.repository.expire_branches_cache if post_received.branches_exist?
post_received.project.repository.expire_branches_cache if post_received.includes_branches?
post_received.enum_for(:changes_refs).with_index do |(oldrev, newrev, ref), index|
service_klass =
......
......@@ -27,12 +27,10 @@ module Gitlab
end
end
def branches_exist?
changes_refs do |_oldrev, _newrev, ref|
return true if Gitlab::Git.branch_ref?(ref) # rubocop:disable Cop/AvoidReturnFromBlocks
def includes_branches?
enum_for(:changes_refs).any? do |_oldrev, _newrev, ref|
Gitlab::Git.branch_ref?(ref)
end
false
end
private
......
......@@ -7,7 +7,7 @@ describe ::Gitlab::GitPostReceive do
subject { described_class.new(project, "project-#{project.id}", changes.dup, {}) }
describe '#branches_exist?' do
describe '#includes_branches?' do
context 'with no branches' do
let(:changes) do
<<~EOF
......@@ -18,7 +18,7 @@ describe ::Gitlab::GitPostReceive do
end
it 'returns false' do
expect(subject.branches_exist?).to be_falsey
expect(subject.includes_branches?).to be_falsey
end
end
......@@ -32,7 +32,7 @@ describe ::Gitlab::GitPostReceive do
end
it 'returns true' do
expect(subject.branches_exist?).to be_truthy
expect(subject.includes_branches?).to be_truthy
end
end
......@@ -45,7 +45,7 @@ describe ::Gitlab::GitPostReceive do
end
it 'returns false' do
expect(subject.branches_exist?).to be_falsey
expect(subject.includes_branches?).to be_falsey
end
end
end
......
......@@ -61,16 +61,21 @@ describe PostReceive do
end
context "branches" do
let(:changes) { '123456 789012 refs/heads/tést' }
let(:changes) do
<<~EOF
'123456 789012 refs/heads/tést1'
'123456 789012 refs/heads/tést2'
EOF
end
it 'expires the branches cache' do
expect(project.repository).to receive(:expire_branches_cache)
expect(project.repository).to receive(:expire_branches_cache).once
described_class.new.perform(gl_repository, key_id, base64_changes)
end
it 'calls Git::BranchPushService' do
expect_next_instance_of(Git::BranchPushService) do |service|
expect_any_instance_of(Git::BranchPushService) do |service|
expect(service).to receive(:execute).and_return(true)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment