diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-05 15:12:12 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-05 15:12:12 +0000 |
commit | 8ec882085e734458ffe0fff8e2e4b72bc3871419 (patch) | |
tree | 6869bb67f3e66e9de828bc47a08577efa1e296c6 /spec/services/branches | |
parent | f63850d9d6c3a81e78c93995c904ed6c0785ef19 (diff) | |
download | gitlab-ce-8ec882085e734458ffe0fff8e2e4b72bc3871419.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/branches')
-rw-r--r-- | spec/services/branches/create_service_spec.rb | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/spec/services/branches/create_service_spec.rb b/spec/services/branches/create_service_spec.rb index 5904ef9b5cf..26cc1a0665e 100644 --- a/spec/services/branches/create_service_spec.rb +++ b/spec/services/branches/create_service_spec.rb @@ -93,7 +93,12 @@ RSpec.describe Branches::CreateService, :use_clean_rails_redis_caching do let(:branches) { { 'master' => 'master', '' => 'master', 'failed_branch' => 'master' } } it 'returns all errors' do - allow(project.repository).to receive(:add_branch).with(user, 'failed_branch', 'master').and_return(false) + allow(project.repository).to receive(:add_branch).with( + user, + 'failed_branch', + 'master', + expire_cache: false + ).and_return(false) expect(subject[:status]).to eq(:error) expect(subject[:message]).to match_array( @@ -117,6 +122,26 @@ RSpec.describe Branches::CreateService, :use_clean_rails_redis_caching do expect(control.by_command(:sadd).count).to eq(1) end end + + context 'without N+1 branch cache expiration' do + let(:branches) { { 'branch_1' => 'master', 'branch_2' => 'master', 'branch_3' => 'master' } } + + it 'triggers branch cache expiration only once' do + expect(project.repository).to receive(:expire_branches_cache).once + + subject + end + + context 'when branches were not added' do + let(:branches) { { 'master' => 'master' } } + + it 'does not trigger branch expiration' do + expect(project.repository).not_to receive(:expire_branches_cache) + + subject + end + end + end end describe '#execute' do |