From 7353a4c64a8ff8f25903f6133421cfd846280db4 Mon Sep 17 00:00:00 2001 From: jbrw Date: Fri, 28 Aug 2020 17:06:07 -0400 Subject: [PATCH] Basic spec for rails_route_from_url (#10558) --- spec/components/url_helper_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/components/url_helper_spec.rb b/spec/components/url_helper_spec.rb index 72ac5acacaf..3c533de935c 100644 --- a/spec/components/url_helper_spec.rb +++ b/spec/components/url_helper_spec.rb @@ -139,6 +139,22 @@ describe UrlHelper do 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 let(:url) { "//s3bucket.s3.dualstack.us-east-1.amazonaws.com/dev/original/3X/2/e/2e6f2ef81b6910ea592cd6d21ee897cd51cf72e4.jpeg" }