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
d840a1ef
Commit
d840a1ef
authored
Jan 26, 2014
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
We can't work with isolated attachment objects anymore
parent
f1db7d7b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
25 deletions
+24
-25
test/attachment_test.rb
+24
-25
No files found.
test/attachment_test.rb
View file @
d840a1ef
...
@@ -346,11 +346,12 @@ class AttachmentTest < Test::Unit::TestCase
...
@@ -346,11 +346,12 @@ class AttachmentTest < Test::Unit::TestCase
context
"An attachment with :hash interpolations"
do
context
"An attachment with :hash interpolations"
do
setup
do
setup
do
@file
=
StringIO
.
new
(
"..."
)
@file
=
StringIO
.
new
(
"...
\n
"
)
end
end
should
"raise if no secret is provided"
do
should
"raise if no secret is provided"
do
@attachment
=
attachment
:path
=>
":hash"
rebuild_model
:path
=>
":hash"
@attachment
=
Dummy
.
new
.
avatar
@attachment
.
assign
@file
@attachment
.
assign
@file
assert_raise
ArgumentError
do
assert_raise
ArgumentError
do
...
@@ -360,29 +361,23 @@ class AttachmentTest < Test::Unit::TestCase
...
@@ -360,29 +361,23 @@ class AttachmentTest < Test::Unit::TestCase
context
"when secret is set"
do
context
"when secret is set"
do
setup
do
setup
do
@attachment
=
attachment
:path
=>
":hash"
,
:hash_secret
=>
"w00t"
rebuild_model
:path
=>
":hash"
,
@attachment
.
stubs
(
:instance_read
).
with
(
:updated_at
).
returns
(
Time
.
at
(
1234567890
))
:hash_secret
=>
"w00t"
,
@attachment
.
stubs
(
:instance_read
).
with
(
:file_name
).
returns
(
"bla.txt"
)
:hash_data
=>
":class/:attachment/:style/:filename"
@attachment
.
instance
.
id
=
1234
@attachment
=
Dummy
.
new
.
avatar
@attachment
.
assign
@file
@attachment
.
assign
@file
end
end
should
"interpolate the hash data"
do
@attachment
.
expects
(
:interpolate
).
with
(
@attachment
.
options
[
:hash_data
],
anything
).
returns
(
"interpolated_stuff"
)
@attachment
.
hash_key
end
should
"result in the correct interpolation"
do
should
"result in the correct interpolation"
do
assert_equal
"fake_models/avatars/1234/original/1234567890"
,
@attachment
.
send
(
:interpolate
,
@attachment
.
options
[
:hash_data
])
assert_equal
"dummies/avatars/original/data.txt"
,
@attachment
.
send
(
:interpolate
,
@attachment
.
options
[
:hash_data
])
assert_equal
"dummies/avatars/thumb/data.txt"
,
@attachment
.
send
(
:interpolate
,
@attachment
.
options
[
:hash_data
],
:thumb
)
end
end
should
"result in a correct hash"
do
should
"result in a correct hash"
do
assert_equal
"d22b617d1bf10016aa7d046d16427ae203f39fce"
,
@attachment
.
path
assert_equal
"e1079a5c34ddbd197ebd0280d07952d98a57fb30"
,
@attachment
.
path
end
assert_equal
"d740189bd3e49ef226fab84c8d45f7ae4126d043"
,
@attachment
.
path
(
:thumb
)
should
"generate a hash digest with the correct style"
do
OpenSSL
::
HMAC
.
expects
(
:hexdigest
).
with
(
anything
,
anything
,
"fake_models/avatars/1234/medium/1234567890"
)
@attachment
.
path
(
"medium"
)
end
end
end
end
end
end
...
@@ -406,15 +401,16 @@ class AttachmentTest < Test::Unit::TestCase
...
@@ -406,15 +401,16 @@ class AttachmentTest < Test::Unit::TestCase
context
"An attachment with a default style and an extension interpolation"
do
context
"An attachment with a default style and an extension interpolation"
do
setup
do
setup
do
@attachment
=
attachment
:path
=>
":basename.:extension"
,
rebuild_model
:path
=>
":basename.:extension"
,
:styles
=>
{
:default
=>
[
"100x100"
,
:png
]
},
:styles
=>
{
:default
=>
[
"100x100"
,
:jpg
]
},
:default_style
=>
:default
:default_style
=>
:default
@file
=
StringIO
.
new
(
"..."
)
@attachment
=
Dummy
.
new
.
avatar
@file
.
stubs
(
:original_filename
).
returns
(
"file.jpg"
)
@file
=
File
.
open
(
fixture_file
(
"5k.png"
))
@file
.
stubs
(
:original_filename
).
returns
(
"file.png"
)
end
end
should
"return the right extension for the path"
do
should
"return the right extension for the path"
do
@attachment
.
assign
(
@file
)
@attachment
.
assign
(
@file
)
assert_equal
"file.
pn
g"
,
@attachment
.
path
assert_equal
"file.
jp
g"
,
@attachment
.
path
end
end
end
end
...
@@ -1091,11 +1087,14 @@ class AttachmentTest < Test::Unit::TestCase
...
@@ -1091,11 +1087,14 @@ class AttachmentTest < Test::Unit::TestCase
context
"when expecting three styles"
do
context
"when expecting three styles"
do
setup
do
setup
do
rebuild_
model
:styles
=>
{
rebuild_
class
:styles
=>
{
:large
=>
[
"400x400"
,
:png
],
:large
=>
[
"400x400"
,
:png
],
:medium
=>
[
"100x100"
,
:gif
],
:medium
=>
[
"100x100"
,
:gif
],
:small
=>
[
"32x32#"
,
:jpg
]
:small
=>
[
"32x32#"
,
:jpg
]
}
}
@instance
=
Dummy
.
new
@instance
.
stubs
(
:id
).
returns
123
@file
=
File
.
new
(
fixture_file
(
"5k.png"
),
'rb'
)
@attachment
=
@instance
.
avatar
@attachment
=
@instance
.
avatar
end
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