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
488ffd25
Commit
488ffd25
authored
Apr 26, 2010
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed support for Rails 2.0.*, ensured support for 2.1.2
parent
d8f45ee0
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
53 deletions
+50
-53
lib/paperclip.rb
+5
-0
lib/paperclip/callback_compatability.rb
+0
-20
shoulda_macros/paperclip.rb
+3
-1
test/attachment_test.rb
+0
-5
test/helper.rb
+34
-9
test/paperclip_test.rb
+8
-18
No files found.
lib/paperclip.rb
View file @
488ffd25
...
...
@@ -312,10 +312,15 @@ module Paperclip
types
=
[
options
.
delete
(
:content_type
)].
flatten
validates_each
(
:"
#{
name
}
_content_type"
,
options
)
do
|
record
,
attr
,
value
|
unless
types
.
any?
{
|
t
|
t
===
value
}
if
record
.
errors
.
method
(
:add
).
arity
==
-
2
message
=
options
[
:message
]
||
"is not one of
#{
types
.
join
(
", "
)
}
"
record
.
errors
.
add
(
:"
#{
name
}
_content_type"
,
message
)
else
record
.
errors
.
add
(
:"
#{
name
}
_content_type"
,
:inclusion
,
:default
=>
options
[
:message
],
:value
=>
value
)
end
end
end
end
# Returns the attachment definitions defined by each call to
# has_attached_file.
...
...
lib/paperclip/callback_compatability.rb
View file @
488ffd25
module
Paperclip
# This module is intended as a compatability shim for the differences in
# callbacks between Rails 2.0 and Rails 2.1.
module
CallbackCompatability
module
Rails20
def
self
.
included
(
base
)
base
.
extend
(
Defining
)
base
.
send
(
:include
,
Running
)
puts
"Including Rails 2.0 Compatability"
end
module
Defining
def
define_paperclip_callbacks
(
*
args
)
end
end
module
Running
def
run_paperclip_callbacks
(
callback
,
opts
=
nil
,
&
blk
)
end
end
end
module
Rails21
def
self
.
included
(
base
)
base
.
extend
(
Defining
)
...
...
shoulda_macros/paperclip.rb
View file @
488ffd25
...
...
@@ -104,8 +104,10 @@ module Paperclip
end
end
class
ActionController
::
Integration
::
Session
#:nodoc:
if
defined?
(
ActionController
::
Integration
::
Session
)
class
ActionController
::
Integration
::
Session
#:nodoc:
include
Paperclip
::
Shoulda
end
end
class
Factory
...
...
test/attachment_test.rb
View file @
488ffd25
...
...
@@ -399,17 +399,12 @@ class AttachmentTest < Test::Unit::TestCase
end
should
"cancel the processing if a before_post_process returns false"
do
begin
$DEBUG
=
true
@dummy
.
expects
(
:do_before_avatar
).
never
@dummy
.
expects
(
:do_after_avatar
).
never
@dummy
.
expects
(
:do_before_all
).
with
().
returns
(
false
)
@dummy
.
expects
(
:do_after_all
)
Paperclip
::
Thumbnail
.
expects
(
:make
).
never
@dummy
.
avatar
=
@file
ensure
$DEBUG
=
false
end
end
should
"cancel the processing if a before_avatar_post_process returns false"
do
...
...
test/helper.rb
View file @
488ffd25
require
'rubygems'
require
'test/unit'
require
'shoulda'
require
'tempfile'
require
'test/unit'
require
'bundler'
gem
'jferris-moch
a'
require
'should
a'
require
'mocha'
gem
'sqlite3-ruby'
case
ENV
[
'RAILS_VERSION'
]
when
'2.1'
then
puts
"Using Rails 2.1.2"
gem
'activerecord'
,
'2.1.2'
gem
'activesupport'
,
'2.1.2'
gem
'actionpack'
,
'2.1.2'
require
'activerecord'
require
'activesupport'
require
'actionpack'
when
'3.0'
then
puts
"Using Rails 3.0.0.beta3"
gem
'activerecord'
,
'3.0.0.beta3'
gem
'activesupport'
,
'3.0.0.beta3'
gem
'actionpack'
,
'3.0.0.beta3'
require
'active_record'
require
'active_support'
require
'action_pack'
else
puts
"Using Rails 2.3.5"
gem
'activerecord'
,
'2.3.5'
gem
'activesupport'
,
'2.3.5'
gem
'actionpack'
,
'2.3.5'
require
'active_record'
require
'active_support'
require
'action_pack'
end
require
'activerecord'
require
'activesupport'
require
'actionpack'
begin
require
'ruby-debug'
rescue
LoadError
puts
"
ruby-debug not load
ed"
rescue
LoadError
=>
e
puts
"
debugger disabl
ed"
end
ROOT
=
File
.
join
(
File
.
dirname
(
__FILE__
),
'..'
)
...
...
test/paperclip_test.rb
View file @
488ffd25
...
...
@@ -41,34 +41,24 @@ class PaperclipTest < Test::Unit::TestCase
end
context
"Calling Paperclip.run and logging"
do
s
etup
do
s
hould
"log the command when :log_command is true"
do
Paperclip
.
options
[
:image_magick_path
]
=
nil
Paperclip
.
options
[
:command_path
]
=
nil
Paperclip
.
stubs
(
:bit_bucket
).
returns
(
"/dev/null"
)
Paperclip
.
stubs
(
:log
)
Paperclip
.
stubs
(
:"`"
).
with
(
"this is the command 2>/dev/null"
)
end
should
"log the command when :log_command is true"
do
Paperclip
.
expects
(
:log
).
with
(
"this is the command 2>/dev/null"
)
Paperclip
.
expects
(
:"`"
).
with
(
"this is the command 2>/dev/null"
)
Paperclip
.
options
[
:log_command
]
=
true
Paperclip
.
run
(
"this"
,
"is the command"
)
assert_received
(
Paperclip
,
:log
)
do
|
p
|
p
.
with
(
"this is the command 2>/dev/null"
)
end
assert_received
(
Paperclip
,
:`
)
do
|
p
|
p
.
with
(
"this is the command 2>/dev/null"
)
end
end
should
"not log the command when :log_command is false"
do
Paperclip
.
options
[
:image_magick_path
]
=
nil
Paperclip
.
options
[
:command_path
]
=
nil
Paperclip
.
stubs
(
:bit_bucket
).
returns
(
"/dev/null"
)
Paperclip
.
expects
(
:log
).
with
(
"this is the command 2>/dev/null"
).
never
Paperclip
.
expects
(
:"`"
).
with
(
"this is the command 2>/dev/null"
)
Paperclip
.
options
[
:log_command
]
=
false
Paperclip
.
run
(
"this"
,
"is the command"
)
assert_received
(
Paperclip
,
:log
)
do
|
p
|
p
.
with
(
"this is the command 2>/dev/null"
).
never
end
assert_received
(
Paperclip
,
:`
)
do
|
p
|
p
.
with
(
"this is the command 2>/dev/null"
)
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