From c1ecfb5de960a675888640a05c75c07217c2d293 Mon Sep 17 00:00:00 2001
From: Douwe Maan <douwe@gitlab.com>
Date: Thu, 22 Oct 2015 15:38:11 +0200
Subject: [PATCH] Disabling caching in test environment because it was causing
 issues with Markdown

---
 config/environments/test.rb          |  2 ++
 config/initializers/session_store.rb | 22 +++++++++++++---------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/config/environments/test.rb b/config/environments/test.rb
index 2d5e7addcd..e03f54c553 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -7,6 +7,8 @@ Gitlab::Application.configure do
   # and recreated between test runs. Don't rely on the data there!
   config.cache_classes = false
 
+  config.cache_store = :null_store
+
   # Configure static asset server for tests with Cache-Control for performance
   config.serve_static_assets = true
   config.static_cache_control = "public, max-age=3600"
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb
index 04ed9e90df..6be21a771e 100644
--- a/config/initializers/session_store.rb
+++ b/config/initializers/session_store.rb
@@ -9,12 +9,16 @@ begin
 rescue
 end
 
-Gitlab::Application.config.session_store(
-  :redis_store, # Using the cookie_store would enable session replay attacks.
-  servers: Gitlab::Application.config.cache_store[1].merge(namespace: 'session:gitlab'), # re-use the Redis config from the Rails cache store
-  key: '_gitlab_session',
-  secure: Gitlab.config.gitlab.https,
-  httponly: true,
-  expire_after: Settings.gitlab['session_expire_delay'] * 60,
-  path: (Gitlab::Application.config.relative_url_root.nil?) ? '/' : Gitlab::Application.config.relative_url_root
-)
+if Rails.env.test?
+  Gitlab::Application.config.session_store :cookie_store, key: "_gitlab_session"
+else
+  Gitlab::Application.config.session_store(
+    :redis_store, # Using the cookie_store would enable session replay attacks.
+    servers: Gitlab::Application.config.cache_store[1].merge(namespace: 'session:gitlab'), # re-use the Redis config from the Rails cache store
+    key: '_gitlab_session',
+    secure: Gitlab.config.gitlab.https,
+    httponly: true,
+    expire_after: Settings.gitlab['session_expire_delay'] * 60,
+    path: (Gitlab::Application.config.relative_url_root.nil?) ? '/' : Gitlab::Application.config.relative_url_root
+  )
+end
-- 
2.30.9