Basic spec for rails_route_from_url (#10558)

This commit is contained in:
jbrw 2020-08-28 17:06:07 -04:00 committed by GitHub
parent c5dc729e77
commit 7353a4c64a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -139,6 +139,22 @@ describe UrlHelper do
end end
end end
describe "#rails_route_from_url" do
it "recognizes a user path" do
result = UrlHelper.rails_route_from_url('http://example.com/u/john_smith')
expect(result[:controller]).to eq("users")
expect(result[:action]).to eq("show")
expect(result[:username]).to eq("john_smith")
end
it "recognizes a user path with unicode characters in the username" do
result = UrlHelper.rails_route_from_url('http://example.com/u/björn_ulvaeus')
expect(result[:controller]).to eq("users")
expect(result[:action]).to eq("show")
expect(result[:username].force_encoding('UTF-8')).to eq("björn_ulvaeus")
end
end
describe "#cook_url" do describe "#cook_url" do
let(:url) { "//s3bucket.s3.dualstack.us-east-1.amazonaws.com/dev/original/3X/2/e/2e6f2ef81b6910ea592cd6d21ee897cd51cf72e4.jpeg" } let(:url) { "//s3bucket.s3.dualstack.us-east-1.amazonaws.com/dev/original/3X/2/e/2e6f2ef81b6910ea592cd6d21ee897cd51cf72e4.jpeg" }