X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/50b2f4f656b82112fce4939da26a1afc6b140e89..da187ad5686e3a6422538de2c8e059b484b372f6:/test/test_helper.rb diff --git a/test/test_helper.rb b/test/test_helper.rb index 378d49bb9..1a60c8234 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -28,6 +28,9 @@ module ActiveSupport include FactoryBot::Syntax::Methods include ActiveJob::TestHelper + # Run tests in parallel with specified workers + parallelize(:workers => :number_of_processors) + ## # takes a block which is executed in the context of a different # ActionController instance. this is used so that code can call methods @@ -115,12 +118,28 @@ module ActiveSupport @request.env["HTTP_AUTHORIZATION"] = format("Basic %{auth}", :auth => Base64.encode64("#{user}:#{pass}")) end + ## + # return request header for HTTP Basic Authorization + def basic_authorization_header(user, pass) + { "Authorization" => format("Basic %{auth}", :auth => Base64.encode64("#{user}:#{pass}")) } + end + + ## + # set request header for HTTP Accept + def http_accept_format(format) + @request.env["HTTP_ACCEPT"] = format + end + ## # set request readers to ask for a particular error format def error_format(format) @request.env["HTTP_X_ERROR_FORMAT"] = format end + def error_format_header(f) + { "X-Error-Format" => f } + end + ## # Used to check that the error header and the forbidden responses are given # when the owner of the changset has their data not marked as public @@ -176,6 +195,11 @@ module ActiveSupport click_on "Login", :match => :first end + def session_for(user) + post login_path, :params => { :username => user.display_name, :password => "test" } + follow_redirect! + end + def xml_for_node(node) doc = OSM::API.new.get_xml_doc doc.root << xml_node_for_node(node)