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
5219c7eb
Commit
5219c7eb
authored
Dec 18, 2019
by
Alexander Belozerov
Committed by
Cuong Tran
Dec 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Fix #570] Change of foreign key should be considered as a column change (#678)
parent
a631f5ad
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
2 deletions
+45
-2
.rubocop_todo.yml
.rubocop_todo.yml
+1
-1
annotate_models.rb
lib/annotate/annotate_models.rb
+1
-1
annotate_models_spec.rb
spec/lib/annotate/annotate_models_spec.rb
+43
-0
No files found.
.rubocop_todo.yml
View file @
5219c7eb
...
@@ -414,7 +414,7 @@ Metrics/AbcSize:
...
@@ -414,7 +414,7 @@ Metrics/AbcSize:
# Configuration parameters: CountComments, ExcludedMethods.
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
# ExcludedMethods: refine
Metrics/BlockLength
:
Metrics/BlockLength
:
Max
:
2
44
Max
:
2
59
# Offense count: 1
# Offense count: 1
# Configuration parameters: CountBlocks.
# Configuration parameters: CountBlocks.
...
...
lib/annotate/annotate_models.rb
View file @
5219c7eb
...
@@ -518,7 +518,7 @@ module AnnotateModels
...
@@ -518,7 +518,7 @@ module AnnotateModels
old_header
=
old_content
.
match
(
header_pattern
).
to_s
old_header
=
old_content
.
match
(
header_pattern
).
to_s
new_header
=
info_block
.
match
(
header_pattern
).
to_s
new_header
=
info_block
.
match
(
header_pattern
).
to_s
column_pattern
=
/^#[\t ]+[\w\*`]+[\t ]+.+$/
column_pattern
=
/^#[\t ]+[\w\*
\.
`]+[\t ]+.+$/
old_columns
=
old_header
&&
old_header
.
scan
(
column_pattern
).
sort
old_columns
=
old_header
&&
old_header
.
scan
(
column_pattern
).
sort
new_columns
=
new_header
&&
new_header
.
scan
(
column_pattern
).
sort
new_columns
=
new_header
&&
new_header
.
scan
(
column_pattern
).
sort
...
...
spec/lib/annotate/annotate_models_spec.rb
View file @
5219c7eb
...
@@ -1758,6 +1758,49 @@ end
...
@@ -1758,6 +1758,49 @@ end
.
to
eq
(
"# START
\n
#{
@schema_info
}
# END
\n\n
#{
@file_content
}
"
)
.
to
eq
(
"# START
\n
#{
@schema_info
}
# END
\n\n
#{
@file_content
}
"
)
end
end
describe
'with existing annotation'
do
context
'of a foreign key'
do
before
do
klass
=
mock_class
(
:users
,
:id
,
[
mock_column
(
:id
,
:integer
),
mock_column
(
:foreign_thing_id
,
:integer
)
],
[],
[
mock_foreign_key
(
'fk_rails_cf2568e89e'
,
'foreign_thing_id'
,
'foreign_things'
,
'id'
,
on_delete: :cascade
)
])
@schema_info
=
AnnotateModels
.
get_schema_info
(
klass
,
'== Schema Info'
,
show_foreign_keys:
true
)
annotate_one_file
end
it
'should update foreign key constraint'
do
klass
=
mock_class
(
:users
,
:id
,
[
mock_column
(
:id
,
:integer
),
mock_column
(
:foreign_thing_id
,
:integer
)
],
[],
[
mock_foreign_key
(
'fk_rails_cf2568e89e'
,
'foreign_thing_id'
,
'foreign_things'
,
'id'
,
on_delete: :restrict
)
])
@schema_info
=
AnnotateModels
.
get_schema_info
(
klass
,
'== Schema Info'
,
show_foreign_keys:
true
)
annotate_one_file
expect
(
File
.
read
(
@model_file_name
)).
to
eq
(
"
#{
@schema_info
}
\n
#{
@file_content
}
"
)
end
end
end
describe
'with existing annotation => :before'
do
describe
'with existing annotation => :before'
do
before
do
before
do
annotate_one_file
position: :before
annotate_one_file
position: :before
...
...
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