File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,14 +6,14 @@ class UriAdapter
66 def initialize ( target )
77 raise Discourse ::InvalidParameters unless target =~ /^https?:\/ \/ /
88
9- @target = URI ( target )
9+ @target = Addressable :: URI . parse ( target )
1010 @original_filename = ::File . basename ( @target . path )
1111 @content = download_content
1212 @tempfile = TempfileFactory . new . generate ( @original_filename )
1313 end
1414
1515 def download_content
16- open ( target )
16+ open ( target . normalize )
1717 end
1818
1919 def copy_to_tempfile ( src )
Original file line number Diff line number Diff line change 1414 describe "#initialize" do
1515
1616 it "has a target" do
17- subject . target . should be_instance_of ( URI :: HTTP )
17+ subject . target . should be_instance_of ( Addressable :: URI )
1818 end
1919
2020 it "has content" do
2929 subject . tempfile . should be_instance_of Tempfile
3030 end
3131
32+ describe "it handles ugly targets" do
33+ let ( :ugly_target ) { "http://cdn.discourse.org/assets/logo with spaces.png" }
34+ subject { UriAdapter . new ( ugly_target ) }
35+
36+ it "handles targets" do
37+ subject . target . should be_instance_of ( Addressable ::URI )
38+ end
39+
40+ it "has content" do
41+ subject . content . should == response
42+ end
43+
44+ it "has an original_filename" do
45+ subject . original_filename . should == "logo with spaces.png"
46+ end
47+
48+ it "has a tempfile" do
49+ subject . tempfile . should be_instance_of Tempfile
50+ end
51+ end
52+
3253 end
3354
3455 describe "#copy_to_tempfile" do
You can’t perform that action at this time.
0 commit comments