summaryrefslogtreecommitdiff
path: root/rubocop/spec_helpers.rb
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-03-30 17:18:12 +0200
committerRémy Coutable <remy@rymai.me>2018-04-06 17:41:52 +0200
commit4b035896c4ed188c0b4ab0e0b5d1d97e4fef9886 (patch)
treefe2c72f9a850a1d16f05e05b85f82cd090b57c7f /rubocop/spec_helpers.rb
parent0fff9db5eac32ae42cc06e31447104ae15c93675 (diff)
downloadgitlab-ce-4b035896c4ed188c0b4ab0e0b5d1d97e4fef9886.tar.gz
Introduce a new FactoriesInMigrationSpecs cop
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'rubocop/spec_helpers.rb')
-rw-r--r--rubocop/spec_helpers.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/rubocop/spec_helpers.rb b/rubocop/spec_helpers.rb
index a702a083958..6c0f0193b1a 100644
--- a/rubocop/spec_helpers.rb
+++ b/rubocop/spec_helpers.rb
@@ -6,7 +6,18 @@ module RuboCop
def in_spec?(node)
path = node.location.expression.source_buffer.name
- !SPEC_HELPERS.include?(File.basename(path)) && path.start_with?(File.join(Dir.pwd, 'spec'))
+ !SPEC_HELPERS.include?(File.basename(path)) &&
+ path.start_with?(File.join(Dir.pwd, 'spec'), File.join(Dir.pwd, 'ee', 'spec'))
+ end
+
+ # Returns true if the given node originated from a migration spec.
+ def in_migration_spec?(node)
+ path = node.location.expression.source_buffer.name
+
+ in_spec?(node) &&
+ path.start_with?(
+ File.join(Dir.pwd, 'spec', 'migrations'),
+ File.join(Dir.pwd, 'ee', 'spec', 'migrations'))
end
end
end