Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
annotate
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
annotate
Commits
91da93dd
Commit
91da93dd
authored
Mar 02, 2016
by
Cuong Tran
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #353 from kfarst/develop
Add unit tests for classified sort option
parents
15e699ed
f89d86f4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
7 deletions
+31
-7
annotate_models_spec.rb
spec/annotate/annotate_models_spec.rb
+31
-7
No files found.
spec/annotate/annotate_models_spec.rb
View file @
91da93dd
...
...
@@ -48,7 +48,7 @@ describe AnnotateModels do
stubs
=
default_options
.
dup
stubs
.
merge!
(
options
)
stubs
[
:name
]
=
name
stubs
[
:type
]
=
type
stubs
[
:type
]
=
type
double
(
"Column"
,
stubs
)
end
...
...
@@ -218,14 +218,20 @@ EOS
describe
"#get_schema_info with custom options"
do
def
self
.
when_called_with
(
options
=
{})
expected
=
options
.
delete
(
:returns
)
default_columns
=
[
[
:id
,
:integer
,
{
:limit
=>
8
}],
[
:active
,
:boolean
,
{
:limit
=>
1
}],
[
:name
,
:string
,
{
:limit
=>
50
}],
[
:notes
,
:text
,
{
:limit
=>
55
}]
]
it
"should work with options =
#{
options
}
"
do
klass
=
mock_class
(
:users
,
:id
,
[
mock_column
(
:id
,
:integer
,
:limit
=>
8
),
mock_column
(
:active
,
:boolean
,
:limit
=>
1
),
mock_column
(
:name
,
:string
,
:limit
=>
50
),
mock_column
(
:notes
,
:text
,
:limit
=>
55
),
])
with_columns
=
(
options
.
delete
(
:with_columns
)
||
default_columns
).
map
do
|
column
|
mock_column
(
column
[
0
],
column
[
1
],
column
[
2
])
end
klass
=
mock_class
(
:users
,
:id
,
with_columns
)
schema_info
=
AnnotateModels
.
get_schema_info
(
klass
,
"Schema Info"
,
options
)
expect
(
schema_info
).
to
eql
(
expected
)
end
...
...
@@ -268,6 +274,24 @@ EOS
# notes :text not null
#
EOS
mocked_columns_without_id
=
[
[
:active
,
:boolean
,
{
:limit
=>
1
}],
[
:name
,
:string
,
{
:limit
=>
50
}],
[
:notes
,
:text
,
{
:limit
=>
55
}]
]
when_called_with
classified_sort:
'yes'
,
with_columns:
mocked_columns_without_id
,
returns:
<<-
EOS
.
strip_heredoc
# Schema Info
#
# Table name: users
#
# active :boolean not null
# name :string(50) not null
# notes :text(55) not null
#
EOS
end
describe
"#get_model_class"
do
...
...
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