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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
lib/paperclip/interpolations.rb
+1
-1
spec/paperclip/interpolations_spec.rb
+8
-1
No files found.
lib/paperclip/interpolations.rb
View file @
06802254
...
@@ -172,7 +172,7 @@ module Paperclip
...
@@ -172,7 +172,7 @@ module Paperclip
when
Integer
when
Integer
(
"%09d"
%
id
).
scan
(
/\d{3}/
).
join
(
"/"
)
(
"%09d"
%
id
).
scan
(
/\d{3}/
).
join
(
"/"
)
when
String
when
String
id
.
scan
(
/.{3}/
).
first
(
3
).
join
(
"/"
)
(
'%9.9s'
%
id
).
tr
(
" "
,
"0"
).
scan
(
/.{3}/
).
join
(
"/"
)
else
else
nil
nil
end
end
...
...
spec/paperclip/interpolations_spec.rb
View file @
06802254
...
@@ -138,7 +138,14 @@ describe Paperclip::Interpolations do
...
@@ -138,7 +138,14 @@ describe Paperclip::Interpolations do
assert_equal
"000/000/023"
,
Paperclip
::
Interpolations
.
id_partition
(
attachment
,
:style
)
assert_equal
"000/000/023"
,
Paperclip
::
Interpolations
.
id_partition
(
attachment
,
:style
)
end
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
=
mock
attachment
.
expects
(
:id
).
returns
(
"32fnj23oio2f"
)
attachment
.
expects
(
:id
).
returns
(
"32fnj23oio2f"
)
attachment
.
expects
(
:instance
).
returns
(
attachment
)
attachment
.
expects
(
:instance
).
returns
(
attachment
)
...
...
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