diff options
Diffstat (limited to 'spec/tooling')
-rw-r--r-- | spec/tooling/danger/database_spec.rb | 51 | ||||
-rw-r--r-- | spec/tooling/danger/project_helper_spec.rb | 1 | ||||
-rw-r--r-- | spec/tooling/docs/deprecation_handling_spec.rb | 2 |
3 files changed, 53 insertions, 1 deletions
diff --git a/spec/tooling/danger/database_spec.rb b/spec/tooling/danger/database_spec.rb new file mode 100644 index 00000000000..ddcfa279dc3 --- /dev/null +++ b/spec/tooling/danger/database_spec.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +require 'gitlab-dangerfiles' +require 'danger' +require 'danger/plugins/internal/helper' +require 'gitlab/dangerfiles/spec_helper' + +require_relative '../../../tooling/danger/database' + +RSpec.describe Tooling::Danger::Database, feature_category: :tooling do + include_context "with dangerfile" + + let(:fake_danger) { DangerSpecHelper.fake_danger.include(described_class) } + let(:migration_files) do + [ + # regular migrations + 'db/migrate/20220901010203_add_widgets_table.rb', + 'db/migrate/20220909010203_add_properties_column.rb', + 'db/migrate/20220910010203_drop_tools_table.rb', + 'db/migrate/20220912010203_add_index_to_widgets_table.rb', + + # post migrations + 'db/post_migrate/20220901010203_add_widgets_table.rb', + 'db/post_migrate/20220909010203_add_properties_column.rb', + 'db/post_migrate/20220910010203_drop_tools_table.rb', + 'db/post_migrate/20220912010203_add_index_to_widgets_table.rb', + + # ee migrations + 'ee/db/migrate/20220901010203_add_widgets_table.rb', + 'ee/db/migrate/20220909010203_add_properties_column.rb', + 'ee/db/migrate/20220910010203_drop_tools_table.rb', + 'ee/db/migrate/20220912010203_add_index_to_widgets_table.rb', + + # geo migrations + 'ee/db/geo/migrate/20220901010203_add_widgets_table.rb', + 'ee/db/geo/migrate/20220909010203_add_properties_column.rb', + 'ee/db/geo/migrate/20220910010203_drop_tools_table.rb', + 'ee/db/geo/migrate/20220912010203_add_index_to_widgets_table.rb' + ] + end + + let(:cutoff) { Date.parse('2022-10-01') - 21 } + + subject(:database) { fake_danger.new } + + describe '#find_migration_files_before' do + it 'returns migrations that are before the cutoff' do + expect(database.find_migration_files_before(migration_files, cutoff).length).to eq(8) + end + end +end diff --git a/spec/tooling/danger/project_helper_spec.rb b/spec/tooling/danger/project_helper_spec.rb index 898c0ffa10c..3910f569400 100644 --- a/spec/tooling/danger/project_helper_spec.rb +++ b/spec/tooling/danger/project_helper_spec.rb @@ -112,6 +112,7 @@ RSpec.describe Tooling::Danger::ProjectHelper do 'scripts/glfm/bar.rb' | [:backend] 'scripts/glfm/bar.js' | [:frontend] + 'scripts/remote_development/run-smoke-test-suite.sh' | [:remote_development] 'scripts/lib/glfm/bar.rb' | [:backend] 'scripts/lib/glfm/bar.js' | [:frontend] 'scripts/bar.rb' | [:backend, :tooling] diff --git a/spec/tooling/docs/deprecation_handling_spec.rb b/spec/tooling/docs/deprecation_handling_spec.rb index 78e613c37c7..feedd246e94 100644 --- a/spec/tooling/docs/deprecation_handling_spec.rb +++ b/spec/tooling/docs/deprecation_handling_spec.rb @@ -14,7 +14,7 @@ RSpec.describe Docs::DeprecationHandling do ['14-10-c.yml', '14-2-b.yml', '14-2-a.yml'] ) # Create dummy YAML data based on file name - allow(YAML).to receive(:load_file) do |file_name| + allow(YAML).to receive(:safe_load_file) do |file_name| { 'title' => file_name[/[a-z]*\.yml/], 'removal_milestone' => file_name[/\d+-\d+/].tr('-', '.') |