Skip to content

Commit

Permalink
Rubocop Update recorder.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieujobin authored Jul 13, 2023
1 parent 5ee006c commit 8eac2aa
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions lib/apipie/extractor/recorder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ def analyze_functional_test(test_context)
@path = request.path
@params = request.request_parameters
if [:POST, :PUT, :PATCH, :DELETE].include?(@verb)
if request.content_type == "multipart/form-data"
@request_data = reformat_multipart_data(@params)
else
@request_data = @params
end
@request_data = request.content_type == "multipart/form-data" ? reformat_multipart_data(@params) : @params
else
@query = request.query_string
end
Expand All @@ -70,13 +66,14 @@ def reformat_multipart_data(form)
lines = ["Content-Type: multipart/form-data; boundary=#{MULTIPART_BOUNDARY}",'']
boundary = "--#{MULTIPART_BOUNDARY}"
form.each do |key, attrs|
if attrs.is_a?(String)
case attrs
when String
lines << boundary << content_disposition(key) << "Content-Length: #{attrs.size}" << '' << attrs
elsif attrs.is_a?(Rack::Test::UploadedFile) || attrs.is_a?(ActionDispatch::Http::UploadedFile)
when Rack::Test::UploadedFile, ActionDispatch::Http::UploadedFile
reformat_uploaded_file(boundary, attrs, key, lines)
elsif attrs.is_a?(Array)
when Array
reformat_array(boundary, attrs, key, lines)
elsif attrs.is_a?(TrueClass) || attrs.is_a?(FalseClass)
when TrueClass, FalseClass
reformat_boolean(boundary, attrs, key, lines)
else
reformat_hash(boundary, attrs, lines)
Expand Down

0 comments on commit 8eac2aa

Please sign in to comment.