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
06802254
Commit
06802254
authored
Sep 09, 2014
by
Strech (Sergey Fedorov)
Committed by
Jon Yurek
Sep 12, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make id partitioning for string similar to integer
parent
87cebf99
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
lib/paperclip/interpolations.rb
+1
-1
spec/paperclip/interpolations_spec.rb
+9
-2
No files found.
lib/paperclip/interpolations.rb
View file @
06802254
...
...
@@ -172,7 +172,7 @@ module Paperclip
when
Integer
(
"%09d"
%
id
).
scan
(
/\d{3}/
).
join
(
"/"
)
when
String
id
.
scan
(
/.{3}/
).
first
(
3
).
join
(
"/"
)
(
'%9.9s'
%
id
).
tr
(
" "
,
"0"
).
scan
(
/.{3}/
).
join
(
"/"
)
else
nil
end
...
...
spec/paperclip/interpolations_spec.rb
View file @
06802254
...
...
@@ -138,7 +138,14 @@ describe Paperclip::Interpolations do
assert_equal
"000/000/023"
,
Paperclip
::
Interpolations
.
id_partition
(
attachment
,
:style
)
end
it
"returns the partitioned id of the attachment when the id is a string"
do
it
"returns the partitioned id of the attachment when the id is a short string"
do
attachment
=
mock
attachment
.
expects
(
:id
).
returns
(
"fnj23"
)
attachment
.
expects
(
:instance
).
returns
(
attachment
)
assert_equal
"000/0fn/j23"
,
Paperclip
::
Interpolations
.
id_partition
(
attachment
,
:style
)
end
it
"returns the partitioned id of the attachment when the id is a long string"
do
attachment
=
mock
attachment
.
expects
(
:id
).
returns
(
"32fnj23oio2f"
)
attachment
.
expects
(
:instance
).
returns
(
attachment
)
...
...
@@ -204,7 +211,7 @@ describe Paperclip::Interpolations do
attachment
.
stubs
(
:original_filename
).
returns
(
"one"
)
assert_equal
"one"
,
Paperclip
::
Interpolations
.
filename
(
attachment
,
:style
)
end
it
"returns the basename when the extension contains regexp special characters"
do
attachment
=
mock
attachment
.
stubs
(
:styles
).
returns
({})
...
...
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