Commit 66e4cd0e authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch '225458-detect-haml-files-in-test_file_finder' into 'master'

Detect haml files in test_file_finder

Closes #225458

See merge request gitlab-org/gitlab!35724
parents 2ae1deeb d0e448cf
......@@ -120,6 +120,22 @@ RSpec.describe Tooling::TestFileFinder do
end
end
context 'when given a haml view' do
let(:file) { 'app/views/admin/users/_user.html.haml' }
it 'returns the matching view spec' do
expect(subject.test_files).to contain_exactly('spec/views/admin/users/_user.html.haml_spec.rb')
end
end
context 'when given a haml view in ee/' do
let(:file) { 'ee/app/views/admin/users/_user.html.haml' }
it 'returns the matching view spec' do
expect(subject.test_files).to contain_exactly('ee/spec/views/admin/users/_user.html.haml_spec.rb')
end
end
context 'when given a migration file' do
let(:file) { 'db/migrate/20191023152913_add_default_and_free_plans.rb' }
......
......@@ -72,9 +72,9 @@ module Tooling
ImpactedTestFile.new do |impact|
impact.associate(%r{app/(.+)\.rb$}) { |match| "spec/#{match[1]}_spec.rb" }
impact.associate(%r{(tooling/)?lib/(.+)\.rb$}) { |match| "spec/#{match[1]}lib/#{match[2]}_spec.rb" }
impact.associate(%r{config/initializers/(.+).rb$}) { |match| "spec/initializers/#{match[1]}_spec.rb" }
impact.associate(%r{config/initializers/(.+)\.rb$}) { |match| "spec/initializers/#{match[1]}_spec.rb" }
impact.associate('db/structure.sql') { 'spec/db/schema_spec.rb' }
impact.associate(%r{db/(?:post_)?migrate/([0-9]+)_(.+).rb$}) do |match|
impact.associate(%r{db/(?:post_)?migrate/([0-9]+)_(.+)\.rb$}) do |match|
[
"spec/migrations/#{match[2]}_spec.rb",
"spec/migrations/#{match[1]}_#{match[2]}_spec.rb"
......@@ -84,8 +84,9 @@ module Tooling
end
def either_impact
ImpactedTestFile.new(prefix: %r{^(#{EE_PREFIX})?}) do |impact|
impact.associate(%r{spec/(.+)_spec.rb$}) { |match| match[0] }
ImpactedTestFile.new(prefix: %r{^(?<prefix>#{EE_PREFIX})?}) do |impact|
impact.associate(%r{app/views/(?<view>.+)\.haml$}) { |match| "#{match[:prefix]}spec/views/#{match[:view]}.haml_spec.rb" }
impact.associate(%r{spec/(.+)_spec\.rb$}) { |match| match[0] }
impact.associate(%r{spec/factories/.+\.rb$}) { 'spec/factories_spec.rb' }
end
end
......
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