BigW Consortium Gitlab

add InspectRequests helper

parent b612bcfc
......@@ -30,12 +30,12 @@ module Gitlab
request_headers = env_http_headers(env)
status, headers, body = @app.call(env)
log_response({
log_response(OpenStruct.new(
url: url,
status_code: status,
request_headers: request_headers,
response_headers: headers
})
))
[status, headers, body]
end
......@@ -52,7 +52,6 @@ module Gitlab
def log_response(response)
@@logged_requests.push(response)
STDOUT.puts response.to_json
end
end
end
......
require 'spec_helper'
feature 'Environment' do
include InspectRequests
given(:project) { create(:project) }
given(:user) { create(:user) }
given(:role) { :developer }
......@@ -193,11 +195,14 @@ feature 'Environment' do
create(:environment, project: project,
name: 'staging-1.0/review',
state: :available)
end
it 'renders a correct environment folder' do
reqs = inspect_requests do
visit folder_project_environments_path(project, id: 'staging-1.0')
end
it 'renders a correct environment folder' do
expect(reqs.first.status_code).to eq(200)
expect(page).to have_content('Environments / staging-1.0')
end
end
......
require_relative './wait_for_requests'
module InspectRequests
extend self
include WaitForRequests
def inspect_requests
Gitlab::Testing::RequestInspectorMiddleware.log_requests!
yield
block_and_wait_for_requests_complete
Gitlab::Testing::RequestInspectorMiddleware.requests
ensure
Gitlab::Testing::RequestInspectorMiddleware.stop_logging!
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment