Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2018-02-02 17:12:28 +0300
committerLin Jen-Shin <godfat@godfat.org>2018-02-07 17:45:02 +0300
commitbbfce29ba8d75df5344dae34dc472dfb3b3acf4b (patch)
tree852a3e8b99d48385106fe24e8bdb36c92ee794b7 /spec/lib/gitlab/middleware
parentd4d564c8e7d2cbc3e6742475a793ba0f630167e3 (diff)
Use a controller to hold request values
So that we don't need to hold env after the request. This makes it much harder to test, especially Rails session is acting weirdly, so we need `dig('flash', 'flashes', 'alert')` to dig the actual flash value.
Diffstat (limited to 'spec/lib/gitlab/middleware')
-rw-r--r--spec/lib/gitlab/middleware/read_only_spec.rb23
1 files changed, 20 insertions, 3 deletions
diff --git a/spec/lib/gitlab/middleware/read_only_spec.rb b/spec/lib/gitlab/middleware/read_only_spec.rb
index 07ba11b93a3..b3c85142b82 100644
--- a/spec/lib/gitlab/middleware/read_only_spec.rb
+++ b/spec/lib/gitlab/middleware/read_only_spec.rb
@@ -11,8 +11,10 @@ describe Gitlab::Middleware::ReadOnly do
RSpec::Matchers.define :disallow_request do
match do |middleware|
- flash = middleware.send(:rack_flash)
- flash['alert'] && flash['alert'].include?('You cannot do writing operations')
+ alert = middleware.env['rack.session'].to_hash
+ .dig('flash', 'flashes', 'alert')
+
+ alert&.include?('You cannot do writing operations')
end
end
@@ -34,7 +36,22 @@ describe Gitlab::Middleware::ReadOnly do
rack.to_app
end
- subject { described_class.new(fake_app) }
+ let(:observe_env) do
+ Module.new do
+ attr_reader :env
+
+ def call(env)
+ @env = env
+ super
+ end
+ end
+ end
+
+ subject do
+ app = described_class.new(fake_app)
+ app.extend(observe_env)
+ app
+ end
let(:request) { Rack::MockRequest.new(rack_stack) }