summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r--spec/lib/gitlab/middleware/read_only_spec.rb14
-rw-r--r--spec/lib/gitlab/middleware/release_env_spec.rb8
2 files changed, 9 insertions, 13 deletions
diff --git a/spec/lib/gitlab/middleware/read_only_spec.rb b/spec/lib/gitlab/middleware/read_only_spec.rb
index b3c85142b82..39ec2f37a83 100644
--- a/spec/lib/gitlab/middleware/read_only_spec.rb
+++ b/spec/lib/gitlab/middleware/read_only_spec.rb
@@ -14,14 +14,14 @@ describe Gitlab::Middleware::ReadOnly do
alert = middleware.env['rack.session'].to_hash
.dig('flash', 'flashes', 'alert')
- alert&.include?('You cannot do writing operations')
+ alert&.include?('You cannot perform write operations')
end
end
RSpec::Matchers.define :disallow_request_in_json do
match do |response|
json_response = JSON.parse(response.body)
- response.body.include?('You cannot do writing operations') && json_response.key?('message')
+ response.body.include?('You cannot perform write operations') && json_response.key?('message')
end
end
@@ -47,14 +47,14 @@ describe Gitlab::Middleware::ReadOnly do
end
end
+ let(:request) { Rack::MockRequest.new(rack_stack) }
+
subject do
- app = described_class.new(fake_app)
- app.extend(observe_env)
- app
+ described_class.new(fake_app).tap do |app|
+ app.extend(observe_env)
+ end
end
- let(:request) { Rack::MockRequest.new(rack_stack) }
-
context 'normal requests to a read-only Gitlab instance' do
let(:fake_app) { lambda { |env| [200, { 'Content-Type' => 'text/plain' }, ['OK']] } }
diff --git a/spec/lib/gitlab/middleware/release_env_spec.rb b/spec/lib/gitlab/middleware/release_env_spec.rb
index 657b705502a..5e3aa877409 100644
--- a/spec/lib/gitlab/middleware/release_env_spec.rb
+++ b/spec/lib/gitlab/middleware/release_env_spec.rb
@@ -1,16 +1,12 @@
require 'spec_helper'
describe Gitlab::Middleware::ReleaseEnv do
- let(:inner_app) { double(:app) }
+ let(:inner_app) { double(:app, call: 'yay') }
let(:app) { described_class.new(inner_app) }
let(:env) { { 'action_controller.instance' => 'something' } }
- before do
- expect(inner_app).to receive(:call).with(env).and_return('yay')
- end
-
describe '#call' do
- it 'calls the app and delete the controller' do
+ it 'calls the app and clears the env' do
result = app.call(env)
expect(result).to eq('yay')