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
d3a74275
Commit
d3a74275
authored
Mar 16, 2012
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some errors on shoulda's matchers
parent
da5d716b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
9 deletions
+6
-9
lib/paperclip/matchers/validate_attachment_presence_matcher.rb
+2
-2
lib/paperclip/matchers/validate_attachment_size_matcher.rb
+4
-7
No files found.
lib/paperclip/matchers/validate_attachment_presence_matcher.rb
View file @
d3a74275
...
...
@@ -39,14 +39,14 @@ module Paperclip
def
error_when_not_valid?
@subject
.
send
(
@attachment_name
).
assign
(
nil
)
@subject
.
valid?
not
@subject
.
errors
[
:"
#{
@attachment_name
}
_file_name"
].
blank
?
@subject
.
errors
[
:"
#{
@attachment_name
}
"
].
present
?
end
def
no_error_when_valid?
@file
=
StringIO
.
new
(
"."
)
@subject
.
send
(
@attachment_name
).
assign
(
@file
)
@subject
.
valid?
@subject
.
errors
[
:"
#{
@attachment_name
}
_file_name
"
].
blank?
@subject
.
errors
[
:"
#{
@attachment_name
}
"
].
blank?
end
end
end
...
...
lib/paperclip/matchers/validate_attachment_size_matcher.rb
View file @
d3a74275
...
...
@@ -18,7 +18,6 @@ module Paperclip
class
ValidateAttachmentSizeMatcher
def
initialize
attachment_name
@attachment_name
=
attachment_name
@low
,
@high
=
0
,
(
1.0
/
0
)
end
def
less_than
size
...
...
@@ -76,21 +75,19 @@ module Paperclip
end
def
lower_than_low?
not
passes_validation_with_size
(
@low
-
1
)
@low
.
nil?
||
!
passes_validation_with_size
(
@low
-
1
)
end
def
higher_than_low?
passes_validation_with_size
(
@low
+
1
)
@low
.
nil?
||
passes_validation_with_size
(
@low
+
1
)
end
def
lower_than_high?
return
true
if
@high
==
(
1.0
/
0
)
passes_validation_with_size
(
@high
-
1
)
@high
.
nil?
||
@high
==
Float
::
INFINITY
||
passes_validation_with_size
(
@high
-
1
)
end
def
higher_than_high?
return
true
if
@high
==
(
1.0
/
0
)
not
passes_validation_with_size
(
@high
+
1
)
@high
.
nil?
||
@high
==
Float
::
INFINITY
||
!
passes_validation_with_size
(
@high
+
1
)
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