Commit 226c4646 authored by alinamihaila's avatar alinamihaila

Match usage_data.rb files for database review

parent b600de60
......@@ -124,7 +124,7 @@ module Gitlab
}.freeze
# First-match win, so be sure to put more specific regex at the top...
CATEGORIES = {
[%r{usage_data}, %r{^(\+|-).*(count|distinct_count)\(.*\)(.*)$}] => [:database, :backend],
[%r{usage_data\.rb}, %r{^(\+|-).*(count|distinct_count)\(.*\)(.*)$}] => [:database, :backend],
%r{\Adoc/.*(\.(md|png|gif|jpg))\z} => :docs,
%r{\A(CONTRIBUTING|LICENSE|MAINTENANCE|PHILOSOPHY|PROCESS|README)(\.md)?\z} => :docs,
......
......@@ -295,9 +295,13 @@ RSpec.describe Gitlab::Danger::Helper do
context 'having specific changes' do
it 'has database and backend categories' do
allow(fake_git).to receive(:diff_for_file).with('usage_data.rb') { double(:diff, patch: "+ count(User.active)") }
changed_files = ['usage_data.rb', 'lib/gitlab/usage_data.rb', 'ee/lib/ee/gitlab/usage_data.rb']
expect(helper.categories_for_file('usage_data.rb')).to eq([:database, :backend])
changed_files.each do |file|
allow(fake_git).to receive(:diff_for_file).with(file) { double(:diff, patch: "+ count(User.active)") }
expect(helper.categories_for_file(file)).to eq([:database, :backend])
end
end
it 'has backend category' do
......@@ -311,6 +315,13 @@ RSpec.describe Gitlab::Danger::Helper do
expect(helper.categories_for_file('user.rb')).to eq([:backend])
end
it 'has backend category for files that are not usage_data.rb' do
changed_file = 'usage_data/topology.rb'
allow(fake_git).to receive(:diff_for_file).with(changed_file) { double(:diff, patch: "+ count(User.active)") }
expect(helper.categories_for_file(changed_file)).to eq([:backend])
end
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