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

disallow_request_matchers.rb « matchers « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cb6f4bedbd561012c508cb2f8a0e81dd8c7f600f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

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|
    json_response = Gitlab::Json.parse(response.body)
    response.body.include?('You cannot perform write operations') && json_response.key?('message')
  end
end