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
27727359
Commit
27727359
authored
Jul 02, 2008
by
Henrik N
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix old tests to pass. Still need to write tests for new functionality.
parent
8697826a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
test/test_attachment.rb
+10
-3
test/test_storage.rb
+1
-1
No files found.
test/test_attachment.rb
View file @
27727359
...
...
@@ -154,6 +154,7 @@ class AttachmentTest < Test::Unit::TestCase
@instance
.
stubs
(
:[]
).
with
(
:test_file_name
).
returns
(
nil
)
@instance
.
stubs
(
:[]
).
with
(
:test_content_type
).
returns
(
nil
)
@instance
.
stubs
(
:[]
).
with
(
:test_file_size
).
returns
(
nil
)
@instance
.
stubs
(
:[]
).
with
(
:test_updated_at
).
returns
(
nil
)
@attachment
=
Paperclip
::
Attachment
.
new
(
:test
,
@instance
)
@file
=
File
.
new
(
File
.
join
(
File
.
dirname
(
__FILE__
),
...
...
@@ -172,11 +173,12 @@ class AttachmentTest < Test::Unit::TestCase
@instance
.
stubs
(
:[]
).
with
(
:test_file_name
).
returns
(
"5k.png"
)
@instance
.
stubs
(
:[]
).
with
(
:test_content_type
).
returns
(
"image/png"
)
@instance
.
stubs
(
:[]
).
with
(
:test_file_size
).
returns
(
12345
)
@instance
.
stubs
(
:[]
).
with
(
:test_updated_at
).
returns
(
Time
.
now
)
end
should
"return a correct url even if the file does not exist"
do
assert_nil
@attachment
.
to_file
assert_
equal
"/tests/41/blah/5k.png"
,
@attachment
.
url
(
:blah
)
assert_
match
%r{^/tests/41/blah/5k
\.
png}
,
@attachment
.
url
(
:blah
)
end
should
"return the proper path when filename has a single .'s"
do
...
...
@@ -200,6 +202,8 @@ class AttachmentTest < Test::Unit::TestCase
context
"and assigned a file"
do
setup
do
now
=
Time
.
mktime
(
2008
)
Time
.
stubs
(
:now
).
returns
(
now
)
@instance
.
expects
(
:[]=
).
with
(
:test_file_name
,
File
.
basename
(
@file
.
path
))
@instance
.
expects
(
:[]=
).
with
(
:test_content_type
,
"image/png"
)
...
...
@@ -207,6 +211,8 @@ class AttachmentTest < Test::Unit::TestCase
@instance
.
expects
(
:[]=
).
with
(
:test_file_name
,
nil
)
@instance
.
expects
(
:[]=
).
with
(
:test_content_type
,
nil
)
@instance
.
expects
(
:[]=
).
with
(
:test_file_size
,
nil
)
@instance
.
expects
(
:[]=
).
with
(
:test_updated_at
,
nil
)
@instance
.
expects
(
:[]=
).
with
(
:test_updated_at
,
now
)
@attachment
.
assign
(
@file
)
end
...
...
@@ -221,8 +227,8 @@ class AttachmentTest < Test::Unit::TestCase
should
"return the real url"
do
assert
@attachment
.
to_file
assert_
equal
"/tests/41/original/5k.png"
,
@attachment
.
url
assert_
equal
"/tests/41/small/5k.jpg"
,
@attachment
.
url
(
:small
)
assert_
match
%r{^/tests/41/original/5k
\.
png}
,
@attachment
.
url
assert_
match
%r{^/tests/41/small/5k
\.
jpg}
,
@attachment
.
url
(
:small
)
end
should
"commit the files to disk"
do
...
...
@@ -259,6 +265,7 @@ class AttachmentTest < Test::Unit::TestCase
@instance
.
expects
(
:[]=
).
with
(
:test_file_name
,
nil
)
@instance
.
expects
(
:[]=
).
with
(
:test_content_type
,
nil
)
@instance
.
expects
(
:[]=
).
with
(
:test_file_size
,
nil
)
@instance
.
expects
(
:[]=
).
with
(
:test_updated_at
,
nil
)
@attachment
.
assign
nil
@attachment
.
save
end
...
...
test/test_storage.rb
View file @
27727359
...
...
@@ -71,7 +71,7 @@ class StorageTest < Test::Unit::TestCase
should
"not get a bucket to get a URL"
do
@dummy
.
avatar
.
expects
(
:s3
).
never
@dummy
.
avatar
.
expects
(
:s3_bucket
).
never
assert_
equal
"https://s3.amazonaws.com/testing/avatars/original/5k.png"
,
@dummy
.
avatar
.
url
assert_
match
%r{^https://s3
\.
amazonaws
\.
com/testing/avatars/original/5k
\.
png}
,
@dummy
.
avatar
.
url
end
context
"and saved"
do
...
...
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