Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-11-08 13:33:01 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-11-08 13:33:01 +0300
commit6edb7e9bb152d919c215f35bd6cb7d52fd3d99be (patch)
treef12ef4b7953932f9b2b9c28313277bf636115bc8 /spec/models/protected_branch_spec.rb
parent305ea394efd2d5afe16234406dede486d9ca37af (diff)
Add latest changes from gitlab-org/gitlab@14-4-stable-ee
Diffstat (limited to 'spec/models/protected_branch_spec.rb')
-rw-r--r--spec/models/protected_branch_spec.rb17
1 files changed, 11 insertions, 6 deletions
diff --git a/spec/models/protected_branch_spec.rb b/spec/models/protected_branch_spec.rb
index 587a9683a8e..f7c723cd134 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