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
f5099413
Commit
f5099413
authored
Aug 18, 2013
by
Cuong Tran
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #126 from davejachimiak/dj-attempt_only_if_table_exists
Attempt model annotation only if table exists
parents
e91eb1e0
a10fa782
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletion
+17
-1
annotate_models.rb
lib/annotate/annotate_models.rb
+1
-1
annotate_models_spec.rb
spec/annotate/annotate_models_spec.rb
+16
-0
No files found.
lib/annotate/annotate_models.rb
View file @
f5099413
...
@@ -411,7 +411,7 @@ module AnnotateModels
...
@@ -411,7 +411,7 @@ module AnnotateModels
def
annotate_model_file
(
annotated
,
file
,
header
,
options
)
def
annotate_model_file
(
annotated
,
file
,
header
,
options
)
begin
begin
klass
=
get_model_class
(
file
)
klass
=
get_model_class
(
file
)
if
klass
&&
klass
<
ActiveRecord
::
Base
&&
!
klass
.
abstract_class?
if
klass
&&
klass
<
ActiveRecord
::
Base
&&
!
klass
.
abstract_class?
&&
klass
.
table_exists?
if
annotate
(
klass
,
file
,
header
,
options
)
if
annotate
(
klass
,
file
,
header
,
options
)
annotated
<<
klass
annotated
<<
klass
end
end
...
...
spec/annotate/annotate_models_spec.rb
View file @
f5099413
...
@@ -461,4 +461,20 @@ end
...
@@ -461,4 +461,20 @@ end
end
end
end
end
end
end
describe
'.annotate_model_file'
do
before
do
class
Foo
<
ActiveRecord
::
Base
;
end
;
AnnotateModels
.
stub
(
:get_model_class
).
with
(
'foo.rb'
)
{
Foo
}
Foo
.
stub
(
:table_exists?
)
{
false
}
end
after
{
Object
.
send
:remove_const
,
'Foo'
}
it
'skips attempt to annotate if no table exists for model'
do
annotate_model_file
=
AnnotateModels
.
annotate_model_file
([],
'foo.rb'
,
nil
,
nil
)
annotate_model_file
.
should
eq
nil
end
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