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
b48ec849
Commit
b48ec849
authored
May 04, 2012
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix test failure from earlier test path cleanup
parent
48736ce5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
18 deletions
+16
-18
test/attachment_test.rb
+4
-4
test/helper.rb
+1
-1
test/paperclip_missing_attachment_styles_test.rb
+10
-12
test/storage/fog_test.rb
+1
-1
No files found.
test/attachment_test.rb
View file @
b48ec849
...
@@ -808,7 +808,7 @@ class AttachmentTest < Test::Unit::TestCase
...
@@ -808,7 +808,7 @@ class AttachmentTest < Test::Unit::TestCase
setup
do
setup
do
@old_defaults
=
Paperclip
::
Attachment
.
default_options
.
dup
@old_defaults
=
Paperclip
::
Attachment
.
default_options
.
dup
Paperclip
::
Attachment
.
default_options
.
merge!
({
Paperclip
::
Attachment
.
default_options
.
merge!
({
:path
=>
":rails_root/
tmp/
:attachment/:class/:style/:id/:basename.:extension"
:path
=>
":rails_root/:attachment/:class/:style/:id/:basename.:extension"
})
})
FileUtils
.
rm_rf
(
"tmp"
)
FileUtils
.
rm_rf
(
"tmp"
)
rebuild_model
rebuild_model
...
@@ -845,7 +845,7 @@ class AttachmentTest < Test::Unit::TestCase
...
@@ -845,7 +845,7 @@ class AttachmentTest < Test::Unit::TestCase
setup
do
setup
do
@old_defaults
=
Paperclip
::
Attachment
.
default_options
.
dup
@old_defaults
=
Paperclip
::
Attachment
.
default_options
.
dup
Paperclip
::
Attachment
.
default_options
.
merge!
({
Paperclip
::
Attachment
.
default_options
.
merge!
({
:path
=>
":rails_root/
tmp/
:attachment/:class/:style/:id/:basename.:extension"
:path
=>
":rails_root/:attachment/:class/:style/:id/:basename.:extension"
})
})
FileUtils
.
rm_rf
(
"tmp"
)
FileUtils
.
rm_rf
(
"tmp"
)
rebuild_model
rebuild_model
...
@@ -893,12 +893,12 @@ class AttachmentTest < Test::Unit::TestCase
...
@@ -893,12 +893,12 @@ class AttachmentTest < Test::Unit::TestCase
end
end
should
"return the proper path when filename has a single .'s"
do
should
"return the proper path when filename has a single .'s"
do
assert_equal
File
.
expand_path
(
"
./test/../
tmp/avatars/dummies/original/
#{
@instance
.
id
}
/5k.png"
),
File
.
expand_path
(
@attachment
.
path
)
assert_equal
File
.
expand_path
(
"tmp/avatars/dummies/original/
#{
@instance
.
id
}
/5k.png"
),
File
.
expand_path
(
@attachment
.
path
)
end
end
should
"return the proper path when filename has multiple .'s"
do
should
"return the proper path when filename has multiple .'s"
do
@attachment
.
stubs
(
:instance_read
).
with
(
:file_name
).
returns
(
"5k.old.png"
)
@attachment
.
stubs
(
:instance_read
).
with
(
:file_name
).
returns
(
"5k.old.png"
)
assert_equal
File
.
expand_path
(
"
./test/../
tmp/avatars/dummies/original/
#{
@instance
.
id
}
/5k.old.png"
),
File
.
expand_path
(
@attachment
.
path
)
assert_equal
File
.
expand_path
(
"tmp/avatars/dummies/original/
#{
@instance
.
id
}
/5k.old.png"
),
File
.
expand_path
(
@attachment
.
path
)
end
end
context
"when expecting three styles"
do
context
"when expecting three styles"
do
...
...
test/helper.rb
View file @
b48ec849
...
@@ -31,7 +31,7 @@ class Test::Unit::TestCase
...
@@ -31,7 +31,7 @@ class Test::Unit::TestCase
def
setup
def
setup
silence_warnings
do
silence_warnings
do
Object
.
const_set
(
:Rails
,
stub
(
'Rails'
))
Object
.
const_set
(
:Rails
,
stub
(
'Rails'
))
Rails
.
stubs
(
:root
).
returns
(
File
.
join
(
ROOT
,
'tmp'
))
Rails
.
stubs
(
:root
).
returns
(
Pathname
.
new
(
ROOT
).
join
(
'tmp'
))
Rails
.
stubs
(
:env
).
returns
(
'test'
)
Rails
.
stubs
(
:env
).
returns
(
'test'
)
Rails
.
stubs
(
:const_defined?
).
with
(
:Railtie
).
returns
(
false
)
Rails
.
stubs
(
:const_defined?
).
with
(
:Railtie
).
returns
(
false
)
end
end
...
...
test/paperclip_missing_attachment_styles_test.rb
View file @
b48ec849
...
@@ -5,34 +5,34 @@ class PaperclipMissingAttachmentStylesTest < Test::Unit::TestCase
...
@@ -5,34 +5,34 @@ class PaperclipMissingAttachmentStylesTest < Test::Unit::TestCase
context
"Paperclip"
do
context
"Paperclip"
do
setup
do
setup
do
Paperclip
.
classes_with_attachments
=
Set
.
new
Paperclip
.
classes_with_attachments
=
Set
.
new
end
end
teardown
do
teardown
do
File
.
unlink
(
Paperclip
.
registered_attachments_styles_path
)
rescue
nil
File
.
unlink
(
Paperclip
.
registered_attachments_styles_path
)
rescue
nil
end
end
should
"be able to keep list of models using it"
do
should
"be able to keep list of models using it"
do
assert_kind_of
Set
,
Paperclip
.
classes_with_attachments
assert_kind_of
Set
,
Paperclip
.
classes_with_attachments
assert
Paperclip
.
classes_with_attachments
.
empty?
,
'list should be empty'
assert
Paperclip
.
classes_with_attachments
.
empty?
,
'list should be empty'
rebuild_model
rebuild_model
assert_equal
[
'Dummy'
].
to_set
,
Paperclip
.
classes_with_attachments
assert_equal
[
'Dummy'
].
to_set
,
Paperclip
.
classes_with_attachments
end
end
should
"enable to get and set path to registered styles file"
do
should
"enable to get and set path to registered styles file"
do
assert_equal
ROOT
.
join
(
'public/system/paperclip_attachments.yml'
).
to_s
,
Paperclip
.
registered_attachments_styles_path
assert_equal
ROOT
.
join
(
'
tmp/
public/system/paperclip_attachments.yml'
).
to_s
,
Paperclip
.
registered_attachments_styles_path
Paperclip
.
registered_attachments_styles_path
=
'/tmp/config/paperclip_attachments.yml'
Paperclip
.
registered_attachments_styles_path
=
'/tmp/config/paperclip_attachments.yml'
assert_equal
'/tmp/config/paperclip_attachments.yml'
,
Paperclip
.
registered_attachments_styles_path
assert_equal
'/tmp/config/paperclip_attachments.yml'
,
Paperclip
.
registered_attachments_styles_path
Paperclip
.
registered_attachments_styles_path
=
nil
Paperclip
.
registered_attachments_styles_path
=
nil
assert_equal
ROOT
.
join
(
'public/system/paperclip_attachments.yml'
).
to_s
,
Paperclip
.
registered_attachments_styles_path
assert_equal
ROOT
.
join
(
'
tmp/
public/system/paperclip_attachments.yml'
).
to_s
,
Paperclip
.
registered_attachments_styles_path
end
end
should
"be able to get current attachment styles"
do
should
"be able to get current attachment styles"
do
assert_equal
Hash
.
new
,
Paperclip
.
send
(
:current_attachments_styles
)
assert_equal
Hash
.
new
,
Paperclip
.
send
(
:current_attachments_styles
)
rebuild_model
:styles
=>
{
:croppable
=>
'600x600>'
,
:big
=>
'1000x1000>'
}
rebuild_model
:styles
=>
{
:croppable
=>
'600x600>'
,
:big
=>
'1000x1000>'
}
expected_hash
=
{
:Dummy
=>
{
:avatar
=>
[
:big
,
:croppable
]}}
expected_hash
=
{
:Dummy
=>
{
:avatar
=>
[
:big
,
:croppable
]}}
assert_equal
expected_hash
,
Paperclip
.
send
(
:current_attachments_styles
)
assert_equal
expected_hash
,
Paperclip
.
send
(
:current_attachments_styles
)
end
end
should
"be able to save current attachment styles for further comparison"
do
should
"be able to save current attachment styles for further comparison"
do
rebuild_model
:styles
=>
{
:croppable
=>
'600x600>'
,
:big
=>
'1000x1000>'
}
rebuild_model
:styles
=>
{
:croppable
=>
'600x600>'
,
:big
=>
'1000x1000>'
}
Paperclip
.
save_current_attachments_styles!
Paperclip
.
save_current_attachments_styles!
...
@@ -68,15 +68,15 @@ class PaperclipMissingAttachmentStylesTest < Test::Unit::TestCase
...
@@ -68,15 +68,15 @@ class PaperclipMissingAttachmentStylesTest < Test::Unit::TestCase
Paperclip
.
save_current_attachments_styles!
Paperclip
.
save_current_attachments_styles!
assert_equal
Hash
.
new
,
Paperclip
.
missing_attachments_styles
assert_equal
Hash
.
new
,
Paperclip
.
missing_attachments_styles
end
end
should
"be able to calculate differences when a new attachment is added to a model"
do
should
"be able to calculate differences when a new attachment is added to a model"
do
rebuild_model
:styles
=>
{
:croppable
=>
'600x600>'
,
:big
=>
'1000x1000>'
}
rebuild_model
:styles
=>
{
:croppable
=>
'600x600>'
,
:big
=>
'1000x1000>'
}
Paperclip
.
save_current_attachments_styles!
Paperclip
.
save_current_attachments_styles!
class
::
Dummy
class
::
Dummy
has_attached_file
:photo
,
:styles
=>
{
:small
=>
'x100'
,
:large
=>
'1000x1000>'
}
has_attached_file
:photo
,
:styles
=>
{
:small
=>
'x100'
,
:large
=>
'1000x1000>'
}
end
end
expected_hash
=
{
expected_hash
=
{
:Dummy
=>
{
:photo
=>
[
:large
,
:small
]}
:Dummy
=>
{
:photo
=>
[
:large
,
:small
]}
}
}
...
@@ -90,7 +90,5 @@ class PaperclipMissingAttachmentStylesTest < Test::Unit::TestCase
...
@@ -90,7 +90,5 @@ class PaperclipMissingAttachmentStylesTest < Test::Unit::TestCase
rebuild_model
:styles
=>
lambda
{
|
attachment
|
attachment
.
instance
.
other
==
'a'
?
{:
thumb
=>
"50x50#"
}
:
{
:large
=>
"400x400"
}
}
rebuild_model
:styles
=>
lambda
{
|
attachment
|
attachment
.
instance
.
other
==
'a'
?
{:
thumb
=>
"50x50#"
}
:
{
:large
=>
"400x400"
}
}
assert_equal
Hash
.
new
,
Paperclip
.
send
(
:current_attachments_styles
)
assert_equal
Hash
.
new
,
Paperclip
.
send
(
:current_attachments_styles
)
end
end
end
end
end
end
test/storage/fog_test.rb
View file @
b48ec849
...
@@ -62,7 +62,7 @@ class FogTest < Test::Unit::TestCase
...
@@ -62,7 +62,7 @@ class FogTest < Test::Unit::TestCase
teardown
{
@file
.
close
}
teardown
{
@file
.
close
}
should
"be able to interpolate the path without blowing up"
do
should
"be able to interpolate the path without blowing up"
do
assert_equal
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"../../public/avatars/5k.png"
)),
assert_equal
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"../../
tmp/
public/avatars/5k.png"
)),
@dummy
.
avatar
.
path
@dummy
.
avatar
.
path
end
end
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