summaryrefslogtreecommitdiff
path: root/spec/models/user_spec.rb
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-11-15 15:47:10 +0100
committerYorick Peterse <yorickpeterse@gmail.com>2017-11-16 14:59:38 +0100
commit3e561736b2eb4866b75c57c01769586f058a2f8d (patch)
tree6e136d37d558b14bfbc2505f8b8f564fa96eab6f /spec/models/user_spec.rb
parent81e94ce1761b48b73be2a8d71938dfe934921e35 (diff)
downloadgitlab-ce-cache-user-keys-count.tar.gz
Cache the number of user SSH keyscache-user-keys-count
By caching the number of personal SSH keys we reduce the number of queries necessary on pages such as ProjectsController#show (which can end up querying this data multiple times). The cache is refreshed/flushed whenever an SSH key is added, removed, or when a user is removed.
Diffstat (limited to 'spec/models/user_spec.rb')
-rw-r--r--spec/models/user_spec.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 88732962071..86647ddf6ce 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -828,7 +828,7 @@ describe User do
end
end
- describe '#require_ssh_key?' do
+ describe '#require_ssh_key?', :use_clean_rails_memory_store_caching do
protocol_and_expectation = {
'http' => false,
'ssh' => true,
@@ -843,6 +843,12 @@ describe User do
expect(user.require_ssh_key?).to eq(expected)
end
end
+
+ it 'returns false when the user has 1 or more SSH keys' do
+ key = create(:personal_key)
+
+ expect(key.user.require_ssh_key?).to eq(false)
+ end
end
end