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:
parent
c11f4456ae
commit
2c3f757951
5 changed files with 42 additions and 51 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue