diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-07-18 01:18:20 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-07-18 01:18:20 +0800 |
commit | aada5273fa260cbd2441e8f1a0c95d951b4977fc (patch) | |
tree | 756f82f4492659adc61ee47f12b9c6a780cb5077 /spec/models/commit_spec.rb | |
parent | 143fc48abac6e278dcda9be4b90cb3ca1291f4d9 (diff) | |
download | gitlab-ce-aada5273fa260cbd2441e8f1a0c95d951b4977fc.tar.gz |
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.rb | 8 |
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 |