2019-07-25 01:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-07-07 00:22:44 -04:00
|
|
|
RSpec::Matchers.define :disallow_request do
|
|
|
|
match do |middleware|
|
|
|
|
alert = middleware.env['rack.session'].to_hash
|
|
|
|
.dig('flash', 'flashes', 'alert')
|
|
|
|
|
|
|
|
alert&.include?('You cannot perform write operations')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
RSpec::Matchers.define :disallow_request_in_json do
|
|
|
|
match do |response|
|
2020-04-30 14:09:38 -04:00
|
|
|
json_response = Gitlab::Json.parse(response.body)
|
2018-07-07 00:22:44 -04:00
|
|
|
response.body.include?('You cannot perform write operations') && json_response.key?('message')
|
|
|
|
end
|
|
|
|
end
|