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:
authorLin Jen-Shin <godfat@godfat.org>2017-07-17 20:18:20 +0300
committerLin Jen-Shin <godfat@godfat.org>2017-07-17 20:18:20 +0300
commitaada5273fa260cbd2441e8f1a0c95d951b4977fc (patch)
tree756f82f4492659adc61ee47f12b9c6a780cb5077 /spec/models/commit_spec.rb
parent143fc48abac6e278dcda9be4b90cb3ca1291f4d9 (diff)
Use RequestStoreWrap for Commit#author
We also try to use instance variable to cache the result if RequestStore is not available, so we could keep the same logic, using the same cache key. Also introduce a way to specify method specific cache key
Diffstat (limited to 'spec/models/commit_spec.rb')
-rw-r--r--spec/models/commit_spec.rb8
1 files changed, 3 insertions, 5 deletions
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb
index 6056d78da4e..528b211c9d6 100644
--- a/spec/models/commit_spec.rb
+++ b/spec/models/commit_spec.rb
@@ -19,17 +19,15 @@ describe Commit, models: true do
expect(commit.author).to eq(user)
end
- it 'caches the author' do
- allow(RequestStore).to receive(:active?).and_return(true)
+ it 'caches the author', :request_store do
user = create(:user, email: commit.author_email)
- expect_any_instance_of(Commit).to receive(:find_author_by_any_email).and_call_original
+ expect(User).to receive(:find_by_any_email).and_call_original
expect(commit.author).to eq(user)
- key = "commit_author:#{commit.author_email}"
+ key = "Commit:author:#{commit.author_email.downcase}"
expect(RequestStore.store[key]).to eq(user)
expect(commit.author).to eq(user)
- RequestStore.store.clear
end
end