Skip to content

Commit

Permalink
Added additional checks to changelog specs
Browse files Browse the repository at this point in the history
- Properly handle issues referring to other rubocop-hq repos
- Only evaluate links at the beginning of a changelog item
- Ensure that the link reference is valid (eg. not [#x] or [])
- Ensure that a changelog item does not contain [Fix(es) #...]
- Fixed improper CHANGELOG.md item
  • Loading branch information
dvandersluis authored and mergify[bot] committed Oct 26, 2020
1 parent 4b73142 commit da35927
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -3079,7 +3079,7 @@
* [#2146](https://github.com/rubocop-hq/rubocop/pull/2146): Add STDIN support. ([@caseywebdev][])
* [#2175](https://github.com/rubocop-hq/rubocop/pull/2175): Files that are excluded from a cop (e.g. using the `Exclude:` config option) are no longer being processed by that cop. ([@bquorning][])
* `Rails/ActionFilter` now handles complete list of methods found in the Rails 4.2 [release notes](https://github.com/rails/rails/blob/4115a12da1409c753c747fd4bab6e612c0c6e51a/guides/source/4_2_release_notes.md#notable-changes-1). ([@MGerrior][])
* [*2138](https://github.com/rubocop-hq/rubocop/issues/2138): Change the offense in `Style/Next` to highlight the condition instead of the iteration. ([@rrosenblum][])
* [#2138](https://github.com/rubocop-hq/rubocop/issues/2138): Change the offense in `Style/Next` to highlight the condition instead of the iteration. ([@rrosenblum][])
* `Style/EmptyLineBetweenDefs` now handles class methods as well. ([@unmanbearpig][])
* Improve handling of `super` in `Style/SymbolProc`. ([@lumeet][])
* `Style/SymbolProc` is applied to methods receiving arguments. ([@lumeet][])
Expand Down
27 changes: 22 additions & 5 deletions spec/project_spec.rb
Expand Up @@ -122,20 +122,31 @@
describe 'link to related issue' do
let(:issues) do
entries.map do |entry|
entry.match(/\[(?<number>[#\d]+)\]\((?<url>[^)]+)\)/)
entry.match(%r{
(?<=^\*\s)
\[(?<ref>(?:(?<repo>rubocop-hq/[a-z_-]+)?\#(?<number>\d+))|.*)\]
\((?<url>[^)]+)\)
}x)
end.compact
end

it 'has an issue number prefixed with #' do
it 'has a reference' do
issues.each do |issue|
expect(issue[:number]).to match(/^#\d+$/)
expect(issue[:ref].blank?).to eq(false)
end
end

it 'has a valid issue number prefixed with #' do
issues.each do |issue|
expect(issue[:number]).to match(/^\d+$/)
end
end

it 'has a valid URL' do
issues.each do |issue|
number = issue[:number].gsub(/\D/, '')
pattern = %r{^https://github\.com/rubocop-hq/rubocop/(?:issues|pull)/#{number}$}
number = issue[:number]&.gsub(/\D/, '')
repo = issue[:repo] || 'rubocop-hq/rubocop'
pattern = %r{^https://github\.com/#{repo}/(?:issues|pull)/#{number}$}
expect(issue[:url]).to match(pattern)
end
end
Expand Down Expand Up @@ -176,6 +187,12 @@
it 'ends with a punctuation' do
expect(bodies).to all(match(/[.!]$/))
end

it 'does not include a [Fix #x] directive' do
bodies.each do |body|
expect(body).not_to match(/\[Fix(es)? \#.*?\]/i)
end
end
end
end
end
Expand Down

0 comments on commit da35927

Please sign in to comment.