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
4db90efe
Commit
4db90efe
authored
Oct 19, 2017
by
Alexander Belozerov
Committed by
Cuong Tran
Oct 18, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Fix #438] model_dir option should allow multiple dirs with comma as described in README
parent
f1fe52e2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletion
+30
-1
annotate_models.rb
lib/annotate/annotate_models.rb
+5
-1
annotate_models_spec.rb
spec/annotate/annotate_models_spec.rb
+25
-0
No files found.
lib/annotate/annotate_models.rb
View file @
4db90efe
...
...
@@ -740,10 +740,14 @@ module AnnotateModels
end
def
parse_options
(
options
=
{})
self
.
model_dir
=
options
[
:model_dir
]
if
options
[
:model_dir
]
self
.
model_dir
=
split_model_dir
(
options
[
:model_dir
])
if
options
[
:model_dir
]
self
.
root_dir
=
options
[
:root_dir
]
if
options
[
:root_dir
]
end
def
split_model_dir
(
option_value
)
option_value
.
split
(
','
).
map
(
&
:strip
).
reject
(
&
:empty?
)
end
# We're passed a name of things that might be
# ActiveRecord models. If we can find the class, and
# if its a subclass of ActiveRecord::Base,
...
...
spec/annotate/annotate_models_spec.rb
View file @
4db90efe
...
...
@@ -72,6 +72,31 @@ describe AnnotateModels do
it
{
expect
(
AnnotateModels
.
quote
(
BigDecimal
.
new
(
'1.2'
))).
to
eql
(
'1.2'
)
}
it
{
expect
(
AnnotateModels
.
quote
([
BigDecimal
.
new
(
'1.2'
)])).
to
eql
([
'1.2'
])
}
describe
'#parse_options'
do
let
(
:options
)
do
{
root_dir:
'/root'
,
model_dir:
'app/models,app/one, app/two ,,app/three'
}
end
it
'sets @root_dir'
do
AnnotateModels
.
send
(
:parse_options
,
options
)
expect
(
AnnotateModels
.
instance_variable_get
(
:@root_dir
)).
to
eq
(
'/root'
)
end
it
'sets @model_dir separated with a comma'
do
AnnotateModels
.
send
(
:parse_options
,
options
)
expected
=
[
'app/models'
,
'app/one'
,
'app/two'
,
'app/three'
]
expect
(
AnnotateModels
.
instance_variable_get
(
:@model_dir
)).
to
eq
(
expected
)
end
end
it
'should get schema info with default options'
do
klass
=
mock_class
(
:users
,
:id
,
...
...
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