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
693b5280
Commit
693b5280
authored
Dec 12, 2011
by
Daniel Schierbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test for #drop_attached_file
parent
b922111b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
test/schema_test.rb
+30
-0
No files found.
test/schema_test.rb
View file @
693b5280
...
...
@@ -7,6 +7,7 @@ class MockSchema
def
initialize
(
table_name
=
nil
)
@table_name
=
table_name
@columns
=
{}
@deleted_columns
=
[]
end
def
column
(
name
,
type
)
...
...
@@ -14,13 +15,19 @@ class MockSchema
end
def
remove_column
(
table_name
,
column_name
)
return
if
@table_name
&&
@table_name
!=
table_name
@columns
.
delete
(
column_name
)
@deleted_columns
.
push
(
column_name
)
end
def
has_column?
(
column_name
)
@columns
.
key?
(
column_name
)
end
def
deleted_column?
(
column_name
)
@deleted_columns
.
include?
(
column_name
)
end
def
type_of
(
column_name
)
@columns
[
column_name
]
end
...
...
@@ -65,4 +72,27 @@ class SchemaTest < Test::Unit::TestCase
assert_equal
:datetime
,
@schema
.
type_of
(
:avatar_updated_at
)
end
end
context
"Migrating down"
do
setup
do
@schema
=
MockSchema
.
new
(
:users
)
@schema
.
drop_attached_file
:users
,
:avatar
end
should
"remove the file_name column"
do
assert
@schema
.
deleted_column?
(
:avatar_file_name
)
end
should
"remove the content_type column"
do
assert
@schema
.
deleted_column?
(
:avatar_content_type
)
end
should
"remove the file_size column"
do
assert
@schema
.
deleted_column?
(
:avatar_file_size
)
end
should
"remove the updated_at column"
do
assert
@schema
.
deleted_column?
(
:avatar_updated_at
)
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