Basic spec for rails_route_from_url (#10558)

Basic spec for rails_route_from_url (#10558)

diff --git a/spec/components/url_helper_spec.rb b/spec/components/url_helper_spec.rb
index 72ac5ac..3c533de 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" }
 

GitHub sha: 7353a4c6

This commit appears in #10558 which was approved by eviltrout. It was merged by jbrw.