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
3ec2599d
Commit
3ec2599d
authored
Sep 25, 2014
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor previous into its own matcher
parent
6ea7c265
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
22 deletions
+27
-22
spec/paperclip/schema_spec.rb
+13
-22
spec/support/matchers/have_column.rb
+14
-0
No files found.
spec/paperclip/schema_spec.rb
View file @
3ec2599d
...
...
@@ -62,7 +62,7 @@ describe Paperclip::Schema do
context
"using #attachment with options"
do
before
do
Dummy
.
connection
.
create_table
:dummies
,
force:
true
do
|
t
|
t
.
attachment
:avatar
,
default:
'1'
,
file_name:
{
default:
'default'
}
t
.
attachment
:avatar
,
default:
1
,
file_name:
{
default:
'default'
}
end
end
...
...
@@ -70,13 +70,9 @@ describe Paperclip::Schema do
defaults_columns
=
[
"avatar_file_name"
,
"avatar_content_type"
,
"avatar_file_size"
]
columns
=
Dummy
.
columns
.
select
{
|
e
|
defaults_columns
.
include?
e
.
name
}
columns
.
each
do
|
column
|
if
column
.
name
==
'avatar_file_name'
expect
(
column
.
default
).
to
eq
(
'default'
)
else
expect
(
column
.
default
.
to_i
).
to
eq
(
1
)
end
end
expect
(
columns
).
to
have_column
(
"avatar_file_name"
).
with_default
(
"default"
)
expect
(
columns
).
to
have_column
(
"avatar_content_type"
).
with_default
(
"1"
)
expect
(
columns
).
to
have_column
(
"avatar_file_size"
).
with_default
(
1
)
end
end
end
...
...
@@ -111,13 +107,9 @@ describe Paperclip::Schema do
defaults_columns
=
[
"avatar_file_name"
,
"avatar_content_type"
,
"avatar_file_size"
]
columns
=
Dummy
.
columns
.
select
{
|
e
|
defaults_columns
.
include?
e
.
name
}
columns
.
each
do
|
column
|
if
column
.
name
==
'avatar_file_name'
expect
(
column
.
default
).
to
eq
(
'default'
)
else
expect
(
column
.
default
.
to_i
).
to
eq
(
1
)
end
end
expect
(
columns
).
to
have_column
(
"avatar_file_name"
).
with_default
(
"default"
)
expect
(
columns
).
to
have_column
(
"avatar_content_type"
).
with_default
(
"1"
)
expect
(
columns
).
to
have_column
(
"avatar_file_size"
).
with_default
(
1
)
end
end
...
...
@@ -149,13 +141,12 @@ describe Paperclip::Schema do
defaults_columns
=
[
"avatar_file_name"
,
"avatar_content_type"
,
"avatar_file_size"
,
"photo_file_name"
,
"photo_content_type"
,
"photo_file_size"
]
columns
=
Dummy
.
columns
.
select
{
|
e
|
defaults_columns
.
include?
e
.
name
}
columns
.
each
do
|
column
|
if
column
.
name
==
'avatar_file_name'
||
column
.
name
==
'photo_file_name'
expect
(
column
.
default
).
to
eq
(
'default'
)
else
expect
(
column
.
default
.
to_i
).
to
eq
(
1
)
end
end
expect
(
columns
).
to
have_column
(
"avatar_file_name"
).
with_default
(
"default"
)
expect
(
columns
).
to
have_column
(
"avatar_content_type"
).
with_default
(
"1"
)
expect
(
columns
).
to
have_column
(
"avatar_file_size"
).
with_default
(
1
)
expect
(
columns
).
to
have_column
(
"photo_file_name"
).
with_default
(
"default"
)
expect
(
columns
).
to
have_column
(
"photo_content_type"
).
with_default
(
"1"
)
expect
(
columns
).
to
have_column
(
"photo_file_size"
).
with_default
(
1
)
end
end
...
...
spec/support/matchers/have_column.rb
0 → 100644
View file @
3ec2599d
RSpec
::
Matchers
.
define
:have_column
do
|
column_name
|
chain
:with_default
do
|
default
|
@default
=
default
end
match
do
|
columns
|
column
=
columns
.
detect
{
|
column
|
column
.
name
==
column_name
}
column
&&
column
.
default
==
@default
end
failure_message_for_should
do
|
columns
|
"expected to find
#{
column_name
}
, default
#{
@default
}
in
#{
columns
.
map
{
|
column
|
[
column
.
name
,
column
.
default
]
}
}"
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