From ea9dd29a76477e73104764d2e7f937bb2ccce8c0 Mon Sep 17 00:00:00 2001
From: Douglas Barbosa Alexandre <dbalexandre@gmail.com>
Date: Mon, 3 Jul 2017 12:38:01 -0300
Subject: [PATCH] Reset @full_path to nil when cache expires

---
 app/models/concerns/routable.rb       | 1 +
 spec/models/concerns/routable_spec.rb | 7 ++++---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/app/models/concerns/routable.rb b/app/models/concerns/routable.rb
index 2305e01d3f1..ee108f010a6 100644
--- a/app/models/concerns/routable.rb
+++ b/app/models/concerns/routable.rb
@@ -108,6 +108,7 @@ module Routable
 
   def expires_full_path_cache
     RequestStore.delete(full_path_key) if RequestStore.active?
+    @full_path = nil
   end
 
   def build_full_path
diff --git a/spec/models/concerns/routable_spec.rb b/spec/models/concerns/routable_spec.rb
index be82a601b36..36aedd2f701 100644
--- a/spec/models/concerns/routable_spec.rb
+++ b/spec/models/concerns/routable_spec.rb
@@ -135,11 +135,12 @@ describe Group, 'Routable' do
   describe '#expires_full_path_cache' do
     context 'with RequestStore active', :request_store do
       it 'expires the full_path cache' do
-        expect(group).to receive(:uncached_full_path).twice.and_call_original
+        expect(group.full_path).to eq('foo')
 
-        3.times { group.full_path }
+        group.route.update(path: 'bar', name: 'bar')
         group.expires_full_path_cache
-        3.times { group.full_path }
+
+        expect(group.full_path).to eq('bar')
       end
     end
   end
-- 
GitLab