FIX: thumbnailing wasn't working with CDN enabled

This commit is contained in:
Régis Hanol
2013-07-22 00:37:23 +02:00
parent 33e3f123b4
commit 649ab85740
5 changed files with 25 additions and 16 deletions

View File

@ -153,11 +153,11 @@ describe Upload do
it "identifies internal or relatives urls" do
Discourse.expects(:base_url_no_prefix).returns("http://discuss.site.com")
Upload.has_been_uploaded?("http://discuss.site.com/uploads/default/42/0123456789ABCDEF.jpg").should == true
Upload.has_been_uploaded?("/uploads/42/0123456789ABCDEF.jpg").should == true
Upload.has_been_uploaded?("/uploads/default/42/0123456789ABCDEF.jpg").should == true
end
it "identifies internal urls when using a CDN" do
ActionController::Base.expects(:asset_host).returns("http://my.cdn.com").twice
Rails.configuration.action_controller.expects(:asset_host).returns("http://my.cdn.com").twice
Upload.has_been_uploaded?("http://my.cdn.com/uploads/default/42/0123456789ABCDEF.jpg").should == true
end
@ -194,10 +194,20 @@ describe Upload do
context ".get_from_url" do
it "works when the file has been uploaded" do
Upload.expects(:where).returns([]).once
Upload.get_from_url("/uploads/default/1/10387531.jpg")
end
it "works when using a cdn" do
Rails.configuration.action_controller.stubs(:asset_host).returns("http://my.cdn.com")
Upload.expects(:where).with(url: "/uploads/default/1/02395732905.jpg").returns([]).once
Upload.get_from_url("http://my.cdn.com/uploads/default/1/02395732905.jpg")
end
it "works only when the file has been uploaded" do
Upload.expects(:has_been_uploaded?).returns(false)
Upload.expects(:where).never
Upload.get_from_url("discourse.org")
Upload.get_from_url("http://domain.com/my/file.txt")
end
end