Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 14e6386

Browse files
dixpacDavid Heinemeier Hansson
authored andcommitted
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
1 parent 50bec56 commit 14e6386

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/service/s3_service_test.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ActiveStorage::Service::S3ServiceTest < ActiveSupport::TestCase
1616
key = SecureRandom.base58(24)
1717
data = "Something else entirely!"
1818
direct_upload_url = @service.url_for_direct_upload(key, expires_in: 5.minutes, content_type: "text/plain", content_length: data.size)
19-
19+
2020
url = URI.parse(direct_upload_url).to_s.split("?").first
2121
query = CGI::parse(URI.parse(direct_upload_url).query).collect { |(k, v)| [ k, v.first ] }.to_h
2222

@@ -30,16 +30,16 @@ class ActiveStorage::Service::S3ServiceTest < ActiveSupport::TestCase
3030
},
3131
debug_output: STDOUT
3232
)
33-
33+
3434
assert_equal data, @service.download(key)
3535
ensure
3636
@service.delete key
3737
end
3838
end
39-
39+
4040
test "signed URL generation" do
41-
assert_match /rails-activestorage\.s3\.amazonaws\.com.*response-content-disposition=inline.*avatar\.png/,
42-
@service.url(FIXTURE_KEY, expires_in: 5.minutes, disposition: :inline, filename: "avatar.png")
41+
assert_match /.+s3.+amazonaws.com.*response-content-disposition=inline.*avatar\.png/,
42+
@service.url(FIXTURE_KEY, expires_in: 5.minutes, disposition: :inline, filename: "avatar.png")
4343
end
4444
end
4545
else

0 commit comments

Comments
 (0)