diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-26 18:36:39 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-26 18:36:39 +0300 |
commit | ee9fd5d06a5ad8fa2d8f0b59614af63eb1b732c3 (patch) | |
tree | 4a10df7aa7944e9fa5139df650f65419b3773ca6 /spec | |
parent | 11657a33e97a26f699638ab26ef934c8298126b7 (diff) |
Add latest changes from gitlab-org/gitlab@14-3-stable-ee
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/protected_branch_spec.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/spec/models/protected_branch_spec.rb b/spec/models/protected_branch_spec.rb index 019c01af672..48aa670c11e 100644 --- a/spec/models/protected_branch_spec.rb +++ b/spec/models/protected_branch_spec.rb @@ -163,27 +163,32 @@ RSpec.describe ProtectedBranch do expect(described_class.protected?(project, 'staging/some-branch')).to eq(false) end + it 'returns false when branch name is nil' do + expect(described_class.protected?(project, nil)).to eq(false) + end + context 'with caching', :use_clean_rails_memory_store_caching do let_it_be(:project) { create(:project, :repository) } - let_it_be(:protected_branch) { create(:protected_branch, project: project, name: "jawn") } + let_it_be(:protected_branch) { create(:protected_branch, project: project, name: "“jawn”") } before do - allow(described_class).to receive(:matching).once.and_call_original + allow(described_class).to receive(:matching).with(protected_branch.name, protected_refs: anything).once.and_call_original + # the original call works and warms the cache - described_class.protected?(project, 'jawn') + described_class.protected?(project, protected_branch.name) end it 'correctly invalidates a cache' do - expect(described_class).to receive(:matching).once.and_call_original + expect(described_class).to receive(:matching).with(protected_branch.name, protected_refs: anything).once.and_call_original create(:protected_branch, project: project, name: "bar") # the cache is invalidated because the project has been "updated" - expect(described_class.protected?(project, 'jawn')).to eq(true) + expect(described_class.protected?(project, protected_branch.name)).to eq(true) end it 'correctly uses the cached version' do expect(described_class).not_to receive(:matching) - expect(described_class.protected?(project, 'jawn')).to eq(true) + expect(described_class.protected?(project, protected_branch.name)).to eq(true) end end end |