debian-mirror-gitlab/spec/support/matchers/disallow_request_matchers.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

18 lines
498 B
Ruby
Raw Permalink Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-11-08 19:23:39 +05:30
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-05-24 23:13:21 +05:30
json_response = Gitlab::Json.parse(response.body)
2018-11-08 19:23:39 +05:30
response.body.include?('You cannot perform write operations') && json_response.key?('message')
end
end