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
a8162558
Commit
a8162558
authored
Nov 09, 2019
by
Kyle Zhao
Committed by
Cuong Tran
Nov 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FIX: Ensure only one line is around the annotation (#669)
parent
693abdd2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
annotate_models.rb
lib/annotate/annotate_models.rb
+2
-2
annotate_models_spec.rb
spec/lib/annotate/annotate_models_spec.rb
+12
-0
No files found.
lib/annotate/annotate_models.rb
View file @
a8162558
...
...
@@ -540,9 +540,9 @@ module AnnotateModels
new_content
=
if
%w(after bottom)
.
include?
(
options
[
position
].
to_s
)
magic_comments_block
+
(
old_content
.
rstrip
+
"
\n\n
"
+
wrapped_info_block
)
elsif
magic_comments_block
.
empty?
magic_comments_block
+
wrapped_info_block
+
"
\n
"
+
old_content
magic_comments_block
+
wrapped_info_block
+
"
\n
"
+
old_content
.
lstrip
else
magic_comments_block
+
"
\n
"
+
wrapped_info_block
+
"
\n
"
+
old_content
magic_comments_block
+
"
\n
"
+
wrapped_info_block
+
"
\n
"
+
old_content
.
lstrip
end
else
# replace the old annotation with the new one
...
...
spec/lib/annotate/annotate_models_spec.rb
View file @
a8162558
...
...
@@ -1803,6 +1803,18 @@ end
end
end
it
'only keeps a single empty line around the annotation (position :before)'
do
content
=
"class User < ActiveRecord::Base
\n
end
\n
"
magic_comments_list_each
do
|
magic_comment
|
schema_info
=
AnnotateModels
.
get_schema_info
(
@klass
,
'== Schema Info'
)
model_file_name
,
=
write_model
'user.rb'
,
"
#{
magic_comment
}
\n\n\n\n
#{
content
}
"
annotate_one_file
position: :before
expect
(
File
.
read
(
model_file_name
)).
to
eq
(
"
#{
magic_comment
}
\n\n
#{
schema_info
}
\n
#{
content
}
"
)
end
end
it
'does not change whitespace between magic comments and model file content (position :after)'
do
content
=
"class User < ActiveRecord::Base
\n
end
\n
"
magic_comments_list_each
do
|
magic_comment
|
...
...
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