mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix regular expression on s3 test URL generation test (#44)
So tests are passing if the bucket name is rails-active storage. But developers specify their own s3 tests configuration (in my case was activestorage-test) then this regex fails. Also the first part is dynamic and based on bucket name and region
This commit is contained in:
parent
50bec56254
commit
14e6386b3c
1 changed files with 5 additions and 5 deletions
|
@ -16,7 +16,7 @@ if SERVICE_CONFIGURATIONS[:s3]
|
||||||
key = SecureRandom.base58(24)
|
key = SecureRandom.base58(24)
|
||||||
data = "Something else entirely!"
|
data = "Something else entirely!"
|
||||||
direct_upload_url = @service.url_for_direct_upload(key, expires_in: 5.minutes, content_type: "text/plain", content_length: data.size)
|
direct_upload_url = @service.url_for_direct_upload(key, expires_in: 5.minutes, content_type: "text/plain", content_length: data.size)
|
||||||
|
|
||||||
url = URI.parse(direct_upload_url).to_s.split("?").first
|
url = URI.parse(direct_upload_url).to_s.split("?").first
|
||||||
query = CGI::parse(URI.parse(direct_upload_url).query).collect { |(k, v)| [ k, v.first ] }.to_h
|
query = CGI::parse(URI.parse(direct_upload_url).query).collect { |(k, v)| [ k, v.first ] }.to_h
|
||||||
|
|
||||||
|
@ -30,16 +30,16 @@ if SERVICE_CONFIGURATIONS[:s3]
|
||||||
},
|
},
|
||||||
debug_output: STDOUT
|
debug_output: STDOUT
|
||||||
)
|
)
|
||||||
|
|
||||||
assert_equal data, @service.download(key)
|
assert_equal data, @service.download(key)
|
||||||
ensure
|
ensure
|
||||||
@service.delete key
|
@service.delete key
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "signed URL generation" do
|
test "signed URL generation" do
|
||||||
assert_match /rails-activestorage\.s3\.amazonaws\.com.*response-content-disposition=inline.*avatar\.png/,
|
assert_match /.+s3.+amazonaws.com.*response-content-disposition=inline.*avatar\.png/,
|
||||||
@service.url(FIXTURE_KEY, expires_in: 5.minutes, disposition: :inline, filename: "avatar.png")
|
@service.url(FIXTURE_KEY, expires_in: 5.minutes, disposition: :inline, filename: "avatar.png")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue