diff options
author | Stan Hu <stanhu@gmail.com> | 2019-06-23 14:34:49 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-06-23 14:38:44 -0700 |
commit | 5fbd0ff460ec982cce570266f53176a8cf071326 (patch) | |
tree | 5e3dfe1868f8b2de7ff8e18899fd25ab8dd25096 /spec/helpers | |
parent | f89a33c9d13db824bb4f4618512d82b6c4e6515a (diff) | |
download | gitlab-ce-5fbd0ff460ec982cce570266f53176a8cf071326.tar.gz |
Memoize non-existent custom appearancessh-strong-memoize-appearances
This saves about 5 SQL calls per page if no custom appearance is
specified.
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/appearances_helper_spec.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/helpers/appearances_helper_spec.rb b/spec/helpers/appearances_helper_spec.rb index a3511e078ce..ed3e31b3c53 100644 --- a/spec/helpers/appearances_helper_spec.rb +++ b/spec/helpers/appearances_helper_spec.rb @@ -8,6 +8,22 @@ describe AppearancesHelper do allow(helper).to receive(:current_user).and_return(user) end + describe '.current_appearance' do + it 'memoizes empty appearance' do + expect(Appearance).to receive(:current).once + + 2.times { helper.current_appearance } + end + + it 'memoizes custom appearance' do + create(:appearance) + + expect(Appearance).to receive(:current).once.and_call_original + + 2.times { helper.current_appearance } + end + end + describe '#header_message' do it 'returns nil when header message field is not set' do create(:appearance) |