diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-04-24 16:01:37 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-04-24 16:01:37 +0000 |
commit | 9d17ad1048779c3e8ff5f8af4d6497a1140cfe33 (patch) | |
tree | e1be814be515e32c561f193f6547768e1a8c7b26 /spec | |
parent | 53301454163bba1b887bbbdba9f91420e951bda1 (diff) | |
parent | a0edaa9210642f23ef3ea4984c6d6f77cbbba878 (diff) | |
download | gitlab-ce-9d17ad1048779c3e8ff5f8af4d6497a1140cfe33.tar.gz |
Merge branch 'sh-optimize-duplicate-routable-full-path' into 'master'
Cache Routable#full_path in RequestStore to reduce duplicate route loads
See merge request !10872
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/concerns/routable_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/models/concerns/routable_spec.rb b/spec/models/concerns/routable_spec.rb index f191605dbdb..221647d7a48 100644 --- a/spec/models/concerns/routable_spec.rb +++ b/spec/models/concerns/routable_spec.rb @@ -194,6 +194,24 @@ describe Group, 'Routable' do it { expect(group.full_path).to eq(group.path) } it { expect(nested_group.full_path).to eq("#{group.full_path}/#{nested_group.path}") } + + context 'with RequestStore active' do + before do + RequestStore.begin! + end + + after do + RequestStore.end! + RequestStore.clear! + end + + it 'does not load the route table more than once' do + expect(group).to receive(:uncached_full_path).once.and_call_original + + 3.times { group.full_path } + expect(group.full_path).to eq(group.path) + end + end end describe '#full_name' do |