Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
a12dec10
Commit
a12dec10
authored
Aug 16, 2013
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed the name of the URL adapter, fix "too many files"
parent
ce604d66
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
8 deletions
+25
-8
lib/paperclip.rb
+1
-1
lib/paperclip/io_adapters/http_url_proxy_adapter.rb
+3
-3
test/io_adapters/http_url_proxy_adapter_test.rb
+21
-4
No files found.
lib/paperclip.rb
View file @
a12dec10
...
...
@@ -191,4 +191,4 @@ require 'paperclip/io_adapters/nil_adapter'
require
'paperclip/io_adapters/attachment_adapter'
require
'paperclip/io_adapters/uploaded_file_adapter'
require
'paperclip/io_adapters/uri_adapter'
require
'paperclip/io_adapters/
url
_adapter'
require
'paperclip/io_adapters/
http_url_proxy
_adapter'
lib/paperclip/io_adapters/
url
_adapter.rb
→
lib/paperclip/io_adapters/
http_url_proxy
_adapter.rb
View file @
a12dec10
module
Paperclip
class
Url
Adapter
<
UriAdapter
class
HttpUrlProxy
Adapter
<
UriAdapter
REGEXP
=
/^https?:\/\//
...
...
@@ -10,6 +10,6 @@ module Paperclip
end
end
Paperclip
.
io_adapters
.
register
Paperclip
::
Url
Adapter
do
|
target
|
String
===
target
&&
target
=~
Paperclip
::
Url
Adapter
::
REGEXP
Paperclip
.
io_adapters
.
register
Paperclip
::
HttpUrlProxy
Adapter
do
|
target
|
String
===
target
&&
target
=~
Paperclip
::
HttpUrlProxy
Adapter
::
REGEXP
end
test/io_adapters/
url
_adapter_test.rb
→
test/io_adapters/
http_url_proxy
_adapter_test.rb
View file @
a12dec10
require
'./test/helper'
class
UrlProxy
Test
<
Test
::
Unit
::
TestCase
class
HttpUrlProxyAdapter
Test
<
Test
::
Unit
::
TestCase
context
"a new instance"
do
setup
do
@open_return
=
StringIO
.
new
(
"xxx"
)
@open_return
.
stubs
(
:content_type
).
returns
(
"image/png"
)
Paperclip
::
Url
Adapter
.
any_instance
.
stubs
(
:download_content
).
returns
(
@open_return
)
Paperclip
::
HttpUrlProxy
Adapter
.
any_instance
.
stubs
(
:download_content
).
returns
(
@open_return
)
@url
=
"http://thoughtbot.com/images/thoughtbot-logo.png"
@subject
=
Paperclip
.
io_adapters
.
for
(
@url
)
end
teardown
do
@subject
.
close
end
should
"return a file name"
do
assert_equal
"thoughtbot-logo.png"
,
@subject
.
original_filename
end
...
...
@@ -56,11 +60,15 @@ class UrlProxyTest < Test::Unit::TestCase
context
"a url with query params"
do
setup
do
Paperclip
::
UrlAdapter
.
any_instance
.
stubs
(
:download_content
).
returns
(
StringIO
.
new
(
"xx
x"
))
Paperclip
::
HttpUrlProxyAdapter
.
any_instance
.
stubs
(
:download_content
).
returns
(
StringIO
.
new
(
"
x"
))
@url
=
"https://github.com/thoughtbot/paperclip?file=test"
@subject
=
Paperclip
.
io_adapters
.
for
(
@url
)
end
teardown
do
@subject
.
close
end
should
"return a file name"
do
assert_equal
"paperclip"
,
@subject
.
original_filename
end
...
...
@@ -68,11 +76,20 @@ class UrlProxyTest < Test::Unit::TestCase
context
"a url with restricted characters in the filename"
do
setup
do
Paperclip
::
UrlAdapter
.
any_instance
.
stubs
(
:download_content
).
returns
(
StringIO
.
new
(
"xx
x"
))
Paperclip
::
HttpUrlProxyAdapter
.
any_instance
.
stubs
(
:download_content
).
returns
(
StringIO
.
new
(
"
x"
))
@url
=
"https://github.com/thoughtbot/paper:clip.jpg"
@subject
=
Paperclip
.
io_adapters
.
for
(
@url
)
end
teardown
do
begin
@subject
.
close
rescue
Exception
=>
e
binding
.
pry
true
end
end
should
"not generate filenames that include restricted characters"
do
assert_equal
"paper_clip.jpg"
,
@subject
.
original_filename
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment