Commit 0e616d71 authored by Sean McGivern's avatar Sean McGivern

Also count specs in new files in Danger check

We have a Danger check that warns if you made changes in app/ but not in
spec/. However, this only checked for changed files - not new files. If
you added an app file with no specs, it wouldn't warn; and it would warn
erroneously if you added a missing spec file while changing a file in
app/.
parent a84469a3
# frozen_string_literal: true
NO_SPECS_LABELS = %w[backstage Documentation QA].freeze NO_SPECS_LABELS = %w[backstage Documentation QA].freeze
NO_NEW_SPEC_MESSAGE = <<~MSG.freeze NO_NEW_SPEC_MESSAGE = <<~MSG.freeze
You've made some app changes, but didn't add any tests. You've made some app changes, but didn't add any tests.
...@@ -9,8 +11,8 @@ def presented_no_changelog_labels ...@@ -9,8 +11,8 @@ def presented_no_changelog_labels
NO_SPECS_LABELS.map { |label| "~#{label}" }.join(', ') NO_SPECS_LABELS.map { |label| "~#{label}" }.join(', ')
end end
has_app_changes = !git.modified_files.grep(%r{\A(ee/)?(app|lib|db/(geo/)?(post_)?migrate)/}).empty? has_app_changes = !helper.all_changed_files.grep(%r{\A(ee/)?(app|lib|db/(geo/)?(post_)?migrate)/}).empty?
has_spec_changes = !git.modified_files.grep(%r{\A(ee/)?spec/}).empty? has_spec_changes = !helper.all_changed_files.grep(%r{\A(ee/)?spec/}).empty?
new_specs_needed = (gitlab.mr_labels & NO_SPECS_LABELS).empty? new_specs_needed = (gitlab.mr_labels & NO_SPECS_LABELS).empty?
if has_app_changes && !has_spec_changes && new_specs_needed if has_app_changes && !has_spec_changes && new_specs_needed
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment