diff options
author | Stan Hu <stanhu@gmail.com> | 2016-07-28 02:42:38 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-07-28 02:42:38 +0300 |
commit | d27e36f35af0c2850c5370a3348d30ce4bcf1a68 (patch) | |
tree | 537e289c3fb5d151fe5c477fe62c27ef6badfa05 /spec/models/commit_spec.rb | |
parent | 8a9fc2b67e5bb6aeabdffa1f91115ac7613a505a (diff) |
Add specs for caching commit author
Diffstat (limited to 'spec/models/commit_spec.rb')
-rw-r--r-- | spec/models/commit_spec.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb index ec1544bf815..c3392ee7440 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -13,6 +13,26 @@ describe Commit, models: true do it { is_expected.to include_module(StaticModel) } end + describe '#author' do + it 'looks up the author in a case-insensitive way' do + user = create(:user, email: commit.author_email.upcase) + expect(commit.author).to eq(user) + end + + it 'caches the author' do + user = create(:user, email: commit.author_email) + expect(RequestStore).to receive(:active?).twice.and_return(true) + expect_any_instance_of(Commit).to receive(:find_author_by_any_email).and_call_original + + expect(commit.author).to eq(user) + key = "commit_author:#{commit.author_email}" + expect(RequestStore.store[key]).to eq(user) + + expect(commit.author).to eq(user) + RequestStore.store.clear + end + end + describe '#to_reference' do it 'returns a String reference to the object' do expect(commit.to_reference).to eq commit.id |