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
d954d5d1
Unverified
Commit
d954d5d1
authored
Feb 16, 2020
by
Ryan
Committed by
GitHub
Feb 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix new lines after comments for rubocop compatibility (#757)
* Fix new lines after comments for rubocop compatability Fix #552, #607
parent
3f3c8867
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
annotate_models.rb
lib/annotate/annotate_models.rb
+2
-2
annotate_models_spec.rb
spec/lib/annotate/annotate_models_spec.rb
+9
-9
No files found.
lib/annotate/annotate_models.rb
View file @
d954d5d1
...
...
@@ -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
.
lstrip
magic_comments_block
+
wrapped_info_block
+
old_content
.
lstrip
else
magic_comments_block
+
"
\n
"
+
wrapped_info_block
+
"
\n
"
+
old_content
.
lstrip
magic_comments_block
+
"
\n
"
+
wrapped_info_block
+
old_content
.
lstrip
end
else
# replace the old annotation with the new one
...
...
spec/lib/annotate/annotate_models_spec.rb
View file @
d954d5d1
...
...
@@ -2495,7 +2495,7 @@ describe AnnotateModels do
it
"should put annotation before class if :position ==
#{
position
}
"
do
annotate_one_file
position:
position
expect
(
File
.
read
(
@model_file_name
))
.
to
eq
(
"
#{
@schema_info
}
\n
#{
@file_content
}
"
)
.
to
eq
(
"
#{
@schema_info
}#{
@file_content
}
"
)
end
end
...
...
@@ -2510,7 +2510,7 @@ describe AnnotateModels do
it
'should wrap annotation if wrapper is specified'
do
annotate_one_file
wrapper_open:
'START'
,
wrapper_close:
'END'
expect
(
File
.
read
(
@model_file_name
))
.
to
eq
(
"# START
\n
#{
@schema_info
}
# END
\n
\n
#{
@file_content
}
"
)
.
to
eq
(
"# START
\n
#{
@schema_info
}
# END
\n
#{
@file_content
}
"
)
end
describe
'with existing annotation'
do
...
...
@@ -2551,7 +2551,7 @@ describe AnnotateModels do
])
@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
}
"
)
expect
(
File
.
read
(
@model_file_name
)).
to
eq
(
"
#{
@schema_info
}#{
@file_content
}
"
)
end
end
end
...
...
@@ -2565,12 +2565,12 @@ describe AnnotateModels do
it
'should retain current position'
do
annotate_one_file
expect
(
File
.
read
(
@model_file_name
)).
to
eq
(
"
#{
@schema_info
}
\n
#{
@file_content
}
"
)
expect
(
File
.
read
(
@model_file_name
)).
to
eq
(
"
#{
@schema_info
}#{
@file_content
}
"
)
end
it
'should retain current position even when :position is changed to :after'
do
annotate_one_file
position: :after
expect
(
File
.
read
(
@model_file_name
)).
to
eq
(
"
#{
@schema_info
}
\n
#{
@file_content
}
"
)
expect
(
File
.
read
(
@model_file_name
)).
to
eq
(
"
#{
@schema_info
}#{
@file_content
}
"
)
end
it
'should change position to :after when force: true'
do
...
...
@@ -2598,7 +2598,7 @@ describe AnnotateModels do
it
'should change position to :before when force: true'
do
annotate_one_file
position: :before
,
force:
true
expect
(
File
.
read
(
@model_file_name
)).
to
eq
(
"
#{
@schema_info
}
\n
#{
@file_content
}
"
)
expect
(
File
.
read
(
@model_file_name
)).
to
eq
(
"
#{
@schema_info
}#{
@file_content
}
"
)
end
end
...
...
@@ -2622,7 +2622,7 @@ describe AnnotateModels do
])
schema_info
=
AnnotateModels
.
get_schema_info
(
klass
,
'== Schema Info'
)
AnnotateModels
.
annotate_one_file
(
model_file_name
,
schema_info
,
position: :before
)
expect
(
File
.
read
(
model_file_name
)).
to
eq
(
"
#{
schema_info
}
\n
#{
file_content
}
"
)
expect
(
File
.
read
(
model_file_name
)).
to
eq
(
"
#{
schema_info
}#{
file_content
}
"
)
end
it
'should not touch magic comments'
do
...
...
@@ -2652,7 +2652,7 @@ describe AnnotateModels do
annotate_one_file
position: :before
schema_info
=
AnnotateModels
.
get_schema_info
(
@klass
,
'== Schema Info'
)
expect
(
File
.
read
(
model_file_name
)).
to
eq
(
"
#{
magic_comment
}
\n\n
#{
schema_info
}
\n
#{
content
}
"
)
expect
(
File
.
read
(
model_file_name
)).
to
eq
(
"
#{
magic_comment
}
\n\n
#{
schema_info
}#{
content
}
"
)
end
end
...
...
@@ -2664,7 +2664,7 @@ describe AnnotateModels do
annotate_one_file
position: :before
expect
(
File
.
read
(
model_file_name
)).
to
eq
(
"
#{
magic_comment
}
\n\n
#{
schema_info
}
\n
#{
content
}
"
)
expect
(
File
.
read
(
model_file_name
)).
to
eq
(
"
#{
magic_comment
}
\n\n
#{
schema_info
}#{
content
}
"
)
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