2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 09:10:25 +08:00

moved has_been_uploaded and uploaded_regex to the Upload model

This commit is contained in:
Régis Hanol 2013-06-16 10:21:01 +02:00
parent c11f4456ae
commit 2c3f757951
5 changed files with 42 additions and 51 deletions

View file

@ -56,4 +56,23 @@ describe Upload do
end
context 'has_been_uploaded?' 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/upload/1234/42/ABCD.jpg").should == true
Upload.has_been_uploaded?("/upload/42/ABCD.jpg").should == true
end
it "identifies internal urls when using a CDN" do
ActionController::Base.expects(:asset_host).returns("http://my.cdn.com").twice
Upload.has_been_uploaded?("http://my.cdn.com/upload/1234/42/ABCD.jpg").should == true
end
it "identifies external urls" do
Upload.has_been_uploaded?("http://domain.com/upload/1234/42/ABCD.jpg").should == false
end
end
end