diff --git a/notifier/spec/fixtures/migration-testing/expected-comment.txt b/notifier/spec/fixtures/migration-testing/expected-comment.txt index d5d0e224c40b02ca0f396cb033fd8393baabb56b..350c9912415a9cd94de46252972eb461dd1552fe 100644 --- a/notifier/spec/fixtures/migration-testing/expected-comment.txt +++ b/notifier/spec/fixtures/migration-testing/expected-comment.txt @@ -103,6 +103,7 @@ Migrations included in this change have been executed on gitlab.com data for tes | Migration | Type | Total runtime | Result | DB size change | | --------- | ---- | ------------- | ------ | -------------- | +| 20210601233122 - UnrelatedMigration | Regular | 10000.0 s | :warning: | +0.00 B | diff --git a/notifier/spec/fixtures/migration-testing/migration-stats.json b/notifier/spec/fixtures/migration-testing/migration-stats.json index 4320d5b448624bd4ff55653a9239fa811a639d19..ae821b4d43d4d7479907bec1820687841448a2a9 100644 --- a/notifier/spec/fixtures/migration-testing/migration-stats.json +++ b/notifier/spec/fixtures/migration-testing/migration-stats.json @@ -606,5 +606,21 @@ "rows": 0 } ] + }, + { + "migration": 20210601233122, + "walltime": 10000, + "success": true, + "total_database_size_change": 0, + "query_statistics": [ + { + "query": "select pg_database_size(current_database()) /*application:test*/", + "calls": 1, + "total_time": 84.903616, + "max_time": 84.903616, + "mean_time": 84.903616, + "rows": 1 + } + ] } ] diff --git a/notifier/spec/fixtures/migration-testing/migrations.json b/notifier/spec/fixtures/migration-testing/migrations.json index 11faadc170e543e7a759343406f15df0bd28f6e0..b04a25c2f17af1c04a66c9dba1bf78e2d161a9d8 100644 --- a/notifier/spec/fixtures/migration-testing/migrations.json +++ b/notifier/spec/fixtures/migration-testing/migrations.json @@ -19,5 +19,12 @@ "name": "CreateTestTable", "type": "regular", "intro_on_current_branch": true + }, + "20210601233122": { + "version": 20210601233122, + "path": "db/migrate/20210601233122_unrelated_migration.rb", + "name": "UnrelatedMigration", + "type": "regular", + "intro_on_current_branch": false } } diff --git a/notifier/spec/warnings_spec.rb b/notifier/spec/warnings_spec.rb index 9d414cee360a883310b495e0ab456246ce3c5c53..4060077457270d2c0767af0223b4bb39b26bb2de 100644 --- a/notifier/spec/warnings_spec.rb +++ b/notifier/spec/warnings_spec.rb @@ -31,5 +31,11 @@ RSpec.describe Warnings do expect(subject.render).to include('should not exceed 100ms') expect(subject.render).to include('222.49203') end + + it 'excludes migrations not introduced on current branch' do + excluded_name = 'UnrelatedMigration' + expect(result.other_migrations.map(&:name)).to include(excluded_name) + expect(subject.render).not_to include(excluded_name) + end end end diff --git a/notifier/warnings.rb b/notifier/warnings.rb index 72976b29f1e97ed3b7c2a133ea19725c2f054961..8e2b9484f22ab980f518c9aa5b509c937c71419d 100644 --- a/notifier/warnings.rb +++ b/notifier/warnings.rb @@ -4,7 +4,7 @@ class Warnings attr_reader :all def initialize(result) - @all = result.migrations.values.select(&:warning?).map(&:warnings).flatten + @all = result.migrations_from_branch.select(&:warning?).map(&:warnings).flatten end def count