From b720ea0613c1ce8db48f300a6d685f74acb9b9bf Mon Sep 17 00:00:00 2001 From: Michael Kozono Date: Tue, 25 Sep 2018 13:19:40 -0700 Subject: Fix RequestStore-related test failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test was failing https://gitlab.com/gitlab-org/gitlab-ee/-/jobs/101444126 because https://gitlab.com/gitlab-org/gitlab-ee/blob/a04056efad6639420b469eced5130751a8cf2757/ee/spec/support/request_store.rb which is in EE only, clears the RequestStore before every test, regardless of whether RequestStore is active. This test is unusual because it sets up RequestStore without it being active, to make sure that the tested code doesn’t attempt to use RequestStore. These two unusual facts combined to cause the failure in EE only. The fix works because of the particular order of RSpec hooks in the test lifecycle. --- spec/lib/gitlab/safe_request_store_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'spec/lib/gitlab/safe_request_store_spec.rb') diff --git a/spec/lib/gitlab/safe_request_store_spec.rb b/spec/lib/gitlab/safe_request_store_spec.rb index 27766fa0eda..c797171dbe2 100644 --- a/spec/lib/gitlab/safe_request_store_spec.rb +++ b/spec/lib/gitlab/safe_request_store_spec.rb @@ -219,11 +219,11 @@ describe Gitlab::SafeRequestStore do end context 'when RequestStore is NOT active' do - around do |example| + before do RequestStore.write('foo', true) + end - example.run - + after do RequestStore.clear! # Clean up end -- cgit v1.2.3