Commit a92693df authored by Mike Greiling's avatar Mike Greiling

add InspectRequests helper

parent b612bcfc
...@@ -30,12 +30,12 @@ module Gitlab ...@@ -30,12 +30,12 @@ module Gitlab
request_headers = env_http_headers(env) request_headers = env_http_headers(env)
status, headers, body = @app.call(env) status, headers, body = @app.call(env)
log_response({ log_response(OpenStruct.new(
url: url, url: url,
status_code: status, status_code: status,
request_headers: request_headers, request_headers: request_headers,
response_headers: headers response_headers: headers
}) ))
[status, headers, body] [status, headers, body]
end end
...@@ -52,7 +52,6 @@ module Gitlab ...@@ -52,7 +52,6 @@ module Gitlab
def log_response(response) def log_response(response)
@@logged_requests.push(response) @@logged_requests.push(response)
STDOUT.puts response.to_json
end end
end end
end end
......
require 'spec_helper' require 'spec_helper'
feature 'Environment' do feature 'Environment' do
include InspectRequests
given(:project) { create(:project) } given(:project) { create(:project) }
given(:user) { create(:user) } given(:user) { create(:user) }
given(:role) { :developer } given(:role) { :developer }
...@@ -193,11 +195,14 @@ feature 'Environment' do ...@@ -193,11 +195,14 @@ feature 'Environment' do
create(:environment, project: project, create(:environment, project: project,
name: 'staging-1.0/review', name: 'staging-1.0/review',
state: :available) state: :available)
visit folder_project_environments_path(project, id: 'staging-1.0')
end end
it 'renders a correct environment folder' do it 'renders a correct environment folder' do
reqs = inspect_requests do
visit folder_project_environments_path(project, id: 'staging-1.0')
end
expect(reqs.first.status_code).to eq(200)
expect(page).to have_content('Environments / staging-1.0') expect(page).to have_content('Environments / staging-1.0')
end end
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