summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/danger/helper_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/danger/helper_spec.rb')
-rw-r--r--spec/lib/gitlab/danger/helper_spec.rb46
1 files changed, 42 insertions, 4 deletions
diff --git a/spec/lib/gitlab/danger/helper_spec.rb b/spec/lib/gitlab/danger/helper_spec.rb
index 92d90ac2fef..2990594c538 100644
--- a/spec/lib/gitlab/danger/helper_spec.rb
+++ b/spec/lib/gitlab/danger/helper_spec.rb
@@ -85,15 +85,29 @@ describe Gitlab::Danger::Helper do
end
end
+ describe '#markdown_list' do
+ it 'creates a markdown list of items' do
+ items = %w[a b]
+
+ expect(helper.markdown_list(items)).to eq("* `a`\n* `b`")
+ end
+
+ it 'wraps items in <details> when there are more than 10 items' do
+ items = ('a'..'k').to_a
+
+ expect(helper.markdown_list(items)).to match(%r{<details>[^<]+</details>})
+ end
+ end
+
describe '#changes_by_category' do
it 'categorizes changed files' do
- expect(fake_git).to receive(:added_files) { %w[foo foo.md foo.rb foo.js db/foo lib/gitlab/database/foo.rb qa/foo ee/changelogs/foo.yml] }
+ expect(fake_git).to receive(:added_files) { %w[foo foo.md foo.rb foo.js db/migrate/foo lib/gitlab/database/foo.rb qa/foo ee/changelogs/foo.yml] }
allow(fake_git).to receive(:modified_files) { [] }
allow(fake_git).to receive(:renamed_files) { [] }
expect(helper.changes_by_category).to eq(
backend: %w[foo.rb],
- database: %w[db/foo lib/gitlab/database/foo.rb],
+ database: %w[db/migrate/foo lib/gitlab/database/foo.rb],
frontend: %w[foo.js],
none: %w[ee/changelogs/foo.yml foo.md],
qa: %w[qa/foo],
@@ -159,8 +173,13 @@ describe Gitlab::Danger::Helper do
'ee/FOO_VERSION' | :unknown
- 'db/foo' | :database
- 'ee/db/foo' | :database
+ 'db/schema.rb' | :database
+ 'db/migrate/foo' | :database
+ 'db/post_migrate/foo' | :database
+ 'ee/db/migrate/foo' | :database
+ 'ee/db/post_migrate/foo' | :database
+ 'ee/db/geo/migrate/foo' | :database
+ 'ee/db/geo/post_migrate/foo' | :database
'app/models/project_authorization.rb' | :database
'app/services/users/refresh_authorized_projects_service.rb' | :database
'lib/gitlab/background_migration.rb' | :database
@@ -174,6 +193,9 @@ describe Gitlab::Danger::Helper do
'lib/gitlab/sql/foo' | :database
'rubocop/cop/migration/foo' | :database
+ 'db/fixtures/foo.rb' | :backend
+ 'ee/db/fixtures/foo.rb' | :backend
+
'qa/foo' | :qa
'ee/qa/foo' | :qa
@@ -224,4 +246,20 @@ describe Gitlab::Danger::Helper do
expect(teammates.map(&:username)).to eq(usernames)
end
end
+
+ describe '#missing_database_labels' do
+ subject { helper.missing_database_labels(current_mr_labels) }
+
+ context 'when current merge request has ~database::review pending' do
+ let(:current_mr_labels) { ['database::review pending', 'feature'] }
+
+ it { is_expected.to match_array(['database']) }
+ end
+
+ context 'when current merge request does not have ~database::review pending' do
+ let(:current_mr_labels) { ['feature'] }
+
+ it { is_expected.to match_array(['database', 'database::review pending']) }
+ end
+ end
end