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
a4d1b0eb
Commit
a4d1b0eb
authored
Apr 30, 2010
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed warnings about #errors in Rails 3
parent
724cc7e1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
7 deletions
+7
-7
lib/paperclip/matchers/validate_attachment_content_type_matcher.rb
+1
-1
lib/paperclip/matchers/validate_attachment_presence_matcher.rb
+2
-2
lib/paperclip/matchers/validate_attachment_size_matcher.rb
+1
-1
test/paperclip_test.rb
+3
-3
No files found.
lib/paperclip/matchers/validate_attachment_content_type_matcher.rb
View file @
a4d1b0eb
...
@@ -57,7 +57,7 @@ module Paperclip
...
@@ -57,7 +57,7 @@ module Paperclip
file
=
StringIO
.
new
(
"."
)
file
=
StringIO
.
new
(
"."
)
file
.
content_type
=
type
file
.
content_type
=
type
(
subject
=
@subject
.
new
).
attachment_for
(
@attachment_name
).
assign
(
file
)
(
subject
=
@subject
.
new
).
attachment_for
(
@attachment_name
).
assign
(
file
)
subject
.
valid?
&&
subject
.
errors
.
on
(
:"
#{
@attachment_name
}
_content_type"
)
.
blank?
subject
.
valid?
&&
subject
.
errors
[
:"
#{
@attachment_name
}
_content_type"
]
.
blank?
end
end
end
end
...
...
lib/paperclip/matchers/validate_attachment_presence_matcher.rb
View file @
a4d1b0eb
...
@@ -39,14 +39,14 @@ module Paperclip
...
@@ -39,14 +39,14 @@ module Paperclip
def
error_when_not_valid?
def
error_when_not_valid?
(
subject
=
@subject
.
new
).
send
(
@attachment_name
).
assign
(
nil
)
(
subject
=
@subject
.
new
).
send
(
@attachment_name
).
assign
(
nil
)
subject
.
valid?
subject
.
valid?
not
subject
.
errors
.
on
(
:"
#{
@attachment_name
}
_file_name"
)
.
blank?
not
subject
.
errors
[
:"
#{
@attachment_name
}
_file_name"
]
.
blank?
end
end
def
no_error_when_valid?
def
no_error_when_valid?
@file
=
StringIO
.
new
(
"."
)
@file
=
StringIO
.
new
(
"."
)
(
subject
=
@subject
.
new
).
send
(
@attachment_name
).
assign
(
@file
)
(
subject
=
@subject
.
new
).
send
(
@attachment_name
).
assign
(
@file
)
subject
.
valid?
subject
.
valid?
subject
.
errors
.
on
(
:"
#{
@attachment_name
}
_file_name"
)
.
blank?
subject
.
errors
[
:"
#{
@attachment_name
}
_file_name"
]
.
blank?
end
end
end
end
end
end
...
...
lib/paperclip/matchers/validate_attachment_size_matcher.rb
View file @
a4d1b0eb
...
@@ -69,7 +69,7 @@ module Paperclip
...
@@ -69,7 +69,7 @@ module Paperclip
(
subject
=
@subject
.
new
).
send
(
@attachment_name
).
assign
(
file
)
(
subject
=
@subject
.
new
).
send
(
@attachment_name
).
assign
(
file
)
subject
.
valid?
subject
.
valid?
subject
.
errors
.
on
(
:"
#{
@attachment_name
}
_file_size"
)
.
blank?
subject
.
errors
[
:"
#{
@attachment_name
}
_file_size"
]
.
blank?
end
end
def
lower_than_low?
def
lower_than_low?
...
...
test/paperclip_test.rb
View file @
a4d1b0eb
...
@@ -235,11 +235,11 @@ class PaperclipTest < Test::Unit::TestCase
...
@@ -235,11 +235,11 @@ class PaperclipTest < Test::Unit::TestCase
end
end
if
validation
==
:presence
if
validation
==
:presence
should
"have an error on the attachment"
do
should
"have an error on the attachment"
do
assert
@dummy
.
errors
.
on
(
:avatar_file_name
)
assert
@dummy
.
errors
[
:avatar_file_name
]
end
end
else
else
should
"not have an error on the attachment"
do
should
"not have an error on the attachment"
do
assert
_nil
@dummy
.
errors
.
on
(
:avatar_file_name
)
,
@dummy
.
errors
.
full_messages
.
join
(
", "
)
assert
@dummy
.
errors
[
:avatar_file_name
].
blank?
,
@dummy
.
errors
.
full_messages
.
join
(
", "
)
end
end
end
end
end
end
...
@@ -288,7 +288,7 @@ class PaperclipTest < Test::Unit::TestCase
...
@@ -288,7 +288,7 @@ class PaperclipTest < Test::Unit::TestCase
end
end
should
"have a file size min/max error message"
do
should
"have a file size min/max error message"
do
assert
_match
%r/between 0 and 10240 bytes/
,
@dummy
.
errors
.
on
(
:avatar_file_size
)
assert
@dummy
.
errors
[
:avatar_file_size
].
any?
{
|
e
|
e
.
match
%r/between 0 and 10240 bytes/
}
end
end
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