summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-05-15 20:24:19 +0000
committerDouwe Maan <douwe@gitlab.com>2017-05-15 20:24:19 +0000
commit950fa32a7c2c25d70bf8b2d495d759ce40bf2d9b (patch)
tree0215a0fe17940cce0118ab434a5636a0b9c63f9b
parentffabab80a7b0cebe322aaf9bb2ca8e617a0b790f (diff)
downloadgitlab-ce-950fa32a7c2c25d70bf8b2d495d759ce40bf2d9b.tar.gz
Revert "Merge branch 'bvl-rename-build-events-to-job-events' into 'master'"
This reverts merge request !11287
-rw-r--r--app/models/ci/build.rb4
-rw-r--r--app/models/hooks/project_hook.rb2
-rw-r--r--app/models/hooks/web_hook.rb2
-rw-r--r--app/models/service.rb4
-rw-r--r--app/views/admin/hooks/index.html.haml2
-rw-r--r--app/views/projects/settings/integrations/_project_hook.html.haml2
-rw-r--r--app/views/shared/web_hooks/_form.html.haml6
-rw-r--r--changelogs/unreleased/bvl-rename-build-events-to-job-events.yml4
-rw-r--r--db/migrate/20170511082759_rename_web_hooks_build_events_to_job_events.rb18
-rw-r--r--db/migrate/20170511083824_rename_services_build_events_to_job_events.rb18
-rw-r--r--db/post_migrate/20170511100900_cleanup_rename_web_hooks_build_events_to_job_events.rb18
-rw-r--r--db/post_migrate/20170511101000_cleanup_rename_services_build_events_to_job_events.rb18
-rw-r--r--db/schema.rb6
-rw-r--r--doc/api/services.md2
-rw-r--r--lib/api/entities.rb4
-rw-r--r--lib/api/project_hooks.rb2
-rw-r--r--lib/api/v3/entities.rb6
-rw-r--r--spec/factories/project_hooks.rb2
-rw-r--r--spec/features/projects/settings/integration_settings_spec.rb2
-rw-r--r--spec/lib/gitlab/import_export/project.json36
-rw-r--r--spec/lib/gitlab/import_export/relation_factory_spec.rb2
-rw-r--r--spec/lib/gitlab/import_export/safe_model_attributes.yml4
-rw-r--r--spec/migrations/migrate_build_events_to_pipeline_events_spec.rb74
-rw-r--r--spec/requests/api/project_hooks_spec.rb4
-rw-r--r--spec/requests/api/v3/project_hooks_spec.rb4
25 files changed, 121 insertions, 125 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 760ec8e5919..3c4a4d93349 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -300,8 +300,8 @@ module Ci
def execute_hooks
return unless project
build_data = Gitlab::DataBuilder::Build.build(self)
- project.execute_hooks(build_data.dup, :job_hooks)
- project.execute_services(build_data.dup, :job_hooks)
+ project.execute_hooks(build_data.dup, :build_hooks)
+ project.execute_services(build_data.dup, :build_hooks)
PagesService.new(build_data).execute
project.running_or_pending_build_count(force: true)
end
diff --git a/app/models/hooks/project_hook.rb b/app/models/hooks/project_hook.rb
index ee6165fd32d..c631e7a7df5 100644
--- a/app/models/hooks/project_hook.rb
+++ b/app/models/hooks/project_hook.rb
@@ -5,7 +5,7 @@ class ProjectHook < WebHook
scope :confidential_issue_hooks, -> { where(confidential_issues_events: true) }
scope :note_hooks, -> { where(note_events: true) }
scope :merge_request_hooks, -> { where(merge_requests_events: true) }
- scope :job_hooks, -> { where(job_events: true) }
+ scope :build_hooks, -> { where(build_events: true) }
scope :pipeline_hooks, -> { where(pipeline_events: true) }
scope :wiki_page_hooks, -> { where(wiki_page_events: true) }
end
diff --git a/app/models/hooks/web_hook.rb b/app/models/hooks/web_hook.rb
index a165fdc312f..7cf03aabd6f 100644
--- a/app/models/hooks/web_hook.rb
+++ b/app/models/hooks/web_hook.rb
@@ -8,7 +8,7 @@ class WebHook < ActiveRecord::Base
default_value_for :note_events, false
default_value_for :merge_requests_events, false
default_value_for :tag_push_events, false
- default_value_for :job_events, false
+ default_value_for :build_events, false
default_value_for :pipeline_events, false
default_value_for :repository_update_events, false
default_value_for :enable_ssl_verification, true
diff --git a/app/models/service.rb b/app/models/service.rb
index 8916f88076e..c71a7d169ec 100644
--- a/app/models/service.rb
+++ b/app/models/service.rb
@@ -12,7 +12,7 @@ class Service < ActiveRecord::Base
default_value_for :merge_requests_events, true
default_value_for :tag_push_events, true
default_value_for :note_events, true
- default_value_for :job_events, true
+ default_value_for :build_events, true
default_value_for :pipeline_events, true
default_value_for :wiki_page_events, true
@@ -40,7 +40,7 @@ class Service < ActiveRecord::Base
scope :confidential_issue_hooks, -> { where(confidential_issues_events: true, active: true) }
scope :merge_request_hooks, -> { where(merge_requests_events: true, active: true) }
scope :note_hooks, -> { where(note_events: true, active: true) }
- scope :job_hooks, -> { where(job_events: true, active: true) }
+ scope :build_hooks, -> { where(build_events: true, active: true) }
scope :pipeline_hooks, -> { where(pipeline_events: true, active: true) }
scope :wiki_page_hooks, -> { where(wiki_page_events: true, active: true) }
scope :external_issue_trackers, -> { issue_trackers.active.without_defaults }
diff --git a/app/views/admin/hooks/index.html.haml b/app/views/admin/hooks/index.html.haml
index e92b8bc39f4..3338b677bf5 100644
--- a/app/views/admin/hooks/index.html.haml
+++ b/app/views/admin/hooks/index.html.haml
@@ -27,7 +27,7 @@
= link_to 'Remove', admin_hook_path(hook), data: { confirm: 'Are you sure?' }, method: :delete, class: 'btn btn-remove btn-sm'
.monospace= hook.url
%div
- - %w(repository_update_events push_events tag_push_events issues_events note_events merge_requests_events job_events).each do |trigger|
+ - %w(repository_update_events push_events tag_push_events issues_events note_events merge_requests_events build_events).each do |trigger|
- if hook.send(trigger)
%span.label.label-gray= trigger.titleize
%span.label.label-gray SSL Verification: #{hook.enable_ssl_verification ? 'enabled' : 'disabled'}
diff --git a/app/views/projects/settings/integrations/_project_hook.html.haml b/app/views/projects/settings/integrations/_project_hook.html.haml
index a6640592dba..8dc276a3bec 100644
--- a/app/views/projects/settings/integrations/_project_hook.html.haml
+++ b/app/views/projects/settings/integrations/_project_hook.html.haml
@@ -3,7 +3,7 @@
.col-md-8.col-lg-7
%strong.light-header= hook.url
%div
- - %w(push_events tag_push_events issues_events confidential_issues_events note_events merge_requests_events job_events pipeline_events wiki_page_events).each do |trigger|
+ - %w(push_events tag_push_events issues_events confidential_issues_events note_events merge_requests_events build_events pipeline_events wiki_page_events).each do |trigger|
- if hook.send(trigger)
%span.label.label-gray.deploy-project-label= trigger.titleize
.col-md-4.col-lg-5.text-right-lg.prepend-top-5
diff --git a/app/views/shared/web_hooks/_form.html.haml b/app/views/shared/web_hooks/_form.html.haml
index 1f0e7629fb4..37c3e61912c 100644
--- a/app/views/shared/web_hooks/_form.html.haml
+++ b/app/views/shared/web_hooks/_form.html.haml
@@ -54,10 +54,10 @@
%p.light
This URL will be triggered when a merge request is created/updated/merged
%li
- = form.check_box :job_events, class: 'pull-left'
+ = form.check_box :build_events, class: 'pull-left'
.prepend-left-20
- = form.label :job_events, class: 'list-label' do
- %strong Job events
+ = form.label :build_events, class: 'list-label' do
+ %strong Jobs events
%p.light
This URL will be triggered when the job status changes
%li
diff --git a/changelogs/unreleased/bvl-rename-build-events-to-job-events.yml b/changelogs/unreleased/bvl-rename-build-events-to-job-events.yml
deleted file mode 100644
index 2ce01a71361..00000000000
--- a/changelogs/unreleased/bvl-rename-build-events-to-job-events.yml
+++ /dev/null
@@ -1,4 +0,0 @@
----
-title: Rename build_events to job_events
-merge_request: 11287
-author:
diff --git a/db/migrate/20170511082759_rename_web_hooks_build_events_to_job_events.rb b/db/migrate/20170511082759_rename_web_hooks_build_events_to_job_events.rb
deleted file mode 100644
index a2320a911b7..00000000000
--- a/db/migrate/20170511082759_rename_web_hooks_build_events_to_job_events.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# See http://doc.gitlab.com/ce/development/migration_style_guide.html
-# for more information on how to write migrations for GitLab.
-
-class RenameWebHooksBuildEventsToJobEvents < ActiveRecord::Migration
- include Gitlab::Database::MigrationHelpers
-
- DOWNTIME = false
-
- disable_ddl_transaction!
-
- def up
- rename_column_concurrently :web_hooks, :build_events, :job_events
- end
-
- def down
- cleanup_concurrent_column_rename :web_hooks, :job_events, :build_events
- end
-end
diff --git a/db/migrate/20170511083824_rename_services_build_events_to_job_events.rb b/db/migrate/20170511083824_rename_services_build_events_to_job_events.rb
deleted file mode 100644
index 303d47078e7..00000000000
--- a/db/migrate/20170511083824_rename_services_build_events_to_job_events.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# See http://doc.gitlab.com/ce/development/migration_style_guide.html
-# for more information on how to write migrations for GitLab.
-
-class RenameServicesBuildEventsToJobEvents < ActiveRecord::Migration
- include Gitlab::Database::MigrationHelpers
-
- DOWNTIME = false
-
- disable_ddl_transaction!
-
- def up
- rename_column_concurrently :services, :build_events, :job_events
- end
-
- def down
- cleanup_concurrent_column_rename :services, :job_events, :build_events
- end
-end
diff --git a/db/post_migrate/20170511100900_cleanup_rename_web_hooks_build_events_to_job_events.rb b/db/post_migrate/20170511100900_cleanup_rename_web_hooks_build_events_to_job_events.rb
deleted file mode 100644
index 281be90163a..00000000000
--- a/db/post_migrate/20170511100900_cleanup_rename_web_hooks_build_events_to_job_events.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# See http://doc.gitlab.com/ce/development/migration_style_guide.html
-# for more information on how to write migrations for GitLab.
-
-class CleanupRenameWebHooksBuildEventsToJobEvents < ActiveRecord::Migration
- include Gitlab::Database::MigrationHelpers
-
- DOWNTIME = false
-
- disable_ddl_transaction!
-
- def up
- cleanup_concurrent_column_rename :web_hooks, :build_events, :job_events
- end
-
- def down
- rename_column_concurrently :web_hooks, :job_events, :build_events
- end
-end
diff --git a/db/post_migrate/20170511101000_cleanup_rename_services_build_events_to_job_events.rb b/db/post_migrate/20170511101000_cleanup_rename_services_build_events_to_job_events.rb
deleted file mode 100644
index 5d26df5688f..00000000000
--- a/db/post_migrate/20170511101000_cleanup_rename_services_build_events_to_job_events.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# See http://doc.gitlab.com/ce/development/migration_style_guide.html
-# for more information on how to write migrations for GitLab.
-
-class CleanupRenameServicesBuildEventsToJobEvents < ActiveRecord::Migration
- include Gitlab::Database::MigrationHelpers
-
- DOWNTIME = false
-
- disable_ddl_transaction!
-
- def up
- cleanup_concurrent_column_rename :services, :build_events, :job_events
- end
-
- def down
- rename_column_concurrently :services, :job_events, :build_events
- end
-end
diff --git a/db/schema.rb b/db/schema.rb
index 513e3696646..a683521c84b 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20170511101000) do
+ActiveRecord::Schema.define(version: 20170508190732) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -1125,13 +1125,13 @@ ActiveRecord::Schema.define(version: 20170511101000) do
t.boolean "merge_requests_events", default: true
t.boolean "tag_push_events", default: true
t.boolean "note_events", default: true, null: false
+ t.boolean "build_events", default: false, null: false
t.string "category", default: "common", null: false
t.boolean "default", default: false
t.boolean "wiki_page_events", default: true
t.boolean "pipeline_events", default: false, null: false
t.boolean "confidential_issues_events", default: true, null: false
t.boolean "commit_events", default: true, null: false
- t.boolean "job_events", default: false, null: false
end
add_index "services", ["project_id"], name: "index_services_on_project_id", using: :btree
@@ -1401,11 +1401,11 @@ ActiveRecord::Schema.define(version: 20170511101000) do
t.boolean "tag_push_events", default: false
t.boolean "note_events", default: false, null: false
t.boolean "enable_ssl_verification", default: true
+ t.boolean "build_events", default: false, null: false
t.boolean "wiki_page_events", default: false, null: false
t.string "token"
t.boolean "pipeline_events", default: false, null: false
t.boolean "confidential_issues_events", default: false, null: false
- t.boolean "job_events", default: false, null: false
t.boolean "repository_update_events", default: false, null: false
end
diff --git a/doc/api/services.md b/doc/api/services.md
index f77d15c2ea1..0f42c256099 100644
--- a/doc/api/services.md
+++ b/doc/api/services.md
@@ -516,7 +516,7 @@ Example response:
"merge_requests_events": true,
"tag_push_events": true,
"note_events": true,
- "job_events": true,
+ "build_events": true,
"pipeline_events": true,
"properties": {
"token": "9koXpg98eAheJpvBs5tK"
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 01cc8e8e1ca..3fc2b453eb6 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -60,7 +60,7 @@ module API
class ProjectHook < Hook
expose :project_id, :issues_events, :merge_requests_events
expose :note_events, :pipeline_events, :wiki_page_events
- expose :job_events
+ expose :build_events, as: :job_events
end
class BasicProjectDetails < Grape::Entity
@@ -470,7 +470,7 @@ module API
expose :id, :title, :created_at, :updated_at, :active
expose :push_events, :issues_events, :merge_requests_events
expose :tag_push_events, :note_events, :pipeline_events
- expose :job_events
+ expose :build_events, as: :job_events
# Expose serialized properties
expose :properties do |service, options|
field_names = service.fields.
diff --git a/lib/api/project_hooks.rb b/lib/api/project_hooks.rb
index 7a345289617..87dfd1573a4 100644
--- a/lib/api/project_hooks.rb
+++ b/lib/api/project_hooks.rb
@@ -54,6 +54,7 @@ module API
end
post ":id/hooks" do
hook_params = declared_params(include_missing: false)
+ hook_params[:build_events] = hook_params.delete(:job_events) { false }
hook = user_project.hooks.new(hook_params)
@@ -77,6 +78,7 @@ module API
hook = user_project.hooks.find(params.delete(:hook_id))
update_params = declared_params(include_missing: false)
+ update_params[:build_events] = update_params.delete(:job_events) if update_params[:job_events]
if hook.update_attributes(update_params)
present hook, with: Entities::ProjectHook
diff --git a/lib/api/v3/entities.rb b/lib/api/v3/entities.rb
index 332f233bf5e..56a9b019f1b 100644
--- a/lib/api/v3/entities.rb
+++ b/lib/api/v3/entities.rb
@@ -238,8 +238,7 @@ module API
class ProjectService < Grape::Entity
expose :id, :title, :created_at, :updated_at, :active
expose :push_events, :issues_events, :merge_requests_events
- expose :tag_push_events, :note_events, :pipeline_events
- expose :job_events, as: :build_events
+ expose :tag_push_events, :note_events, :build_events, :pipeline_events
# Expose serialized properties
expose :properties do |service, options|
field_names = service.fields.
@@ -251,8 +250,7 @@ module API
class ProjectHook < ::API::Entities::Hook
expose :project_id, :issues_events, :merge_requests_events
- expose :note_events, :pipeline_events, :wiki_page_events
- expose :job_events, as: :build_events
+ expose :note_events, :build_events, :pipeline_events, :wiki_page_events
end
class Issue < ::API::Entities::Issue
diff --git a/spec/factories/project_hooks.rb b/spec/factories/project_hooks.rb
index cd754ea235f..0210e871a63 100644
--- a/spec/factories/project_hooks.rb
+++ b/spec/factories/project_hooks.rb
@@ -14,7 +14,7 @@ FactoryGirl.define do
issues_events true
confidential_issues_events true
note_events true
- job_events true
+ build_events true
pipeline_events true
wiki_page_events true
end
diff --git a/spec/features/projects/settings/integration_settings_spec.rb b/spec/features/projects/settings/integration_settings_spec.rb
index d3232f0cc16..7909234556e 100644
--- a/spec/features/projects/settings/integration_settings_spec.rb
+++ b/spec/features/projects/settings/integration_settings_spec.rb
@@ -52,7 +52,6 @@ feature 'Integration settings', feature: true do
fill_in 'hook_url', with: url
check 'Tag push events'
check 'Enable SSL verification'
- check 'Job events'
click_button 'Add webhook'
@@ -60,7 +59,6 @@ feature 'Integration settings', feature: true do
expect(page).to have_content('SSL Verification: enabled')
expect(page).to have_content('Push Events')
expect(page).to have_content('Tag Push Events')
- expect(page).to have_content('Job events')
end
scenario 'edit existing webhook' do
diff --git a/spec/lib/gitlab/import_export/project.json b/spec/lib/gitlab/import_export/project.json
index e3599d6fe59..fdbb6a0556d 100644
--- a/spec/lib/gitlab/import_export/project.json
+++ b/spec/lib/gitlab/import_export/project.json
@@ -6997,7 +6997,7 @@
"merge_requests_events": true,
"tag_push_events": true,
"note_events": true,
- "job_events": true,
+ "build_events": true,
"type": "TeamcityService",
"category": "ci",
"default": false,
@@ -7041,7 +7041,7 @@
"merge_requests_events": true,
"tag_push_events": true,
"note_events": true,
- "job_events": true,
+ "build_events": true,
"type": "RedmineService",
"category": "issue_tracker",
"default": false,
@@ -7063,7 +7063,7 @@
"merge_requests_events": true,
"tag_push_events": true,
"note_events": true,
- "job_events": true,
+ "build_events": true,
"type": "PushoverService",
"category": "common",
"default": false,
@@ -7085,7 +7085,7 @@
"merge_requests_events": true,
"tag_push_events": true,
"note_events": true,
- "job_events": true,
+ "build_events": true,
"type": "PivotalTrackerService",
"category": "common",
"default": false,
@@ -7108,7 +7108,7 @@
"merge_requests_events": true,
"tag_push_events": true,
"note_events": true,
- "job_events": true,
+ "build_events": true,
"type": "JiraService",
"category": "issue_tracker",
"default": false,
@@ -7130,7 +7130,7 @@
"merge_requests_events": true,
"tag_push_events": true,
"note_events": true,
- "job_events": true,
+ "build_events": true,
"type": "IrkerService",
"category": "common",
"default": false,
@@ -7174,7 +7174,7 @@
"merge_requests_events": true,
"tag_push_events": true,
"note_events": true,
- "job_events": true,
+ "build_events": true,
"type": "GemnasiumService",
"category": "common",
"default": false,
@@ -7196,7 +7196,7 @@
"merge_requests_events": true,
"tag_push_events": true,
"note_events": true,
- "job_events": true,
+ "build_events": true,
"type": "FlowdockService",
"category": "common",
"default": false,
@@ -7218,7 +7218,7 @@
"merge_requests_events": true,
"tag_push_events": true,
"note_events": true,
- "job_events": true,
+ "build_events": true,
"type": "ExternalWikiService",
"category": "common",
"default": false,
@@ -7240,7 +7240,7 @@
"merge_requests_events": true,
"tag_push_events": true,
"note_events": true,
- "job_events": true,
+ "build_events": true,
"type": "EmailsOnPushService",
"category": "common",
"default": false,
@@ -7262,7 +7262,7 @@
"merge_requests_events": true,
"tag_push_events": true,
"note_events": true,
- "job_events": true,
+ "build_events": true,
"type": "DroneCiService",
"category": "ci",
"default": false,
@@ -7284,7 +7284,7 @@
"merge_requests_events": true,
"tag_push_events": true,
"note_events": true,
- "job_events": true,
+ "build_events": true,
"type": "CustomIssueTrackerService",
"category": "issue_tracker",
"default": false,
@@ -7306,7 +7306,7 @@
"merge_requests_events": true,
"tag_push_events": true,
"note_events": true,
- "job_events": true,
+ "build_events": true,
"type": "CampfireService",
"category": "common",
"default": false,
@@ -7328,7 +7328,7 @@
"merge_requests_events": true,
"tag_push_events": true,
"note_events": true,
- "job_events": true,
+ "build_events": true,
"type": "BuildkiteService",
"category": "ci",
"default": false,
@@ -7350,7 +7350,7 @@
"merge_requests_events": true,
"tag_push_events": true,
"note_events": true,
- "job_events": true,
+ "build_events": true,
"type": "BambooService",
"category": "ci",
"default": false,
@@ -7372,7 +7372,7 @@
"merge_requests_events": true,
"tag_push_events": true,
"note_events": true,
- "job_events": true,
+ "build_events": true,
"type": "AssemblaService",
"category": "common",
"default": false,
@@ -7394,7 +7394,7 @@
"merge_requests_events": true,
"tag_push_events": true,
"note_events": true,
- "job_events": true,
+ "build_events": true,
"type": "AssemblaService",
"category": "common",
"default": false,
@@ -7416,7 +7416,7 @@
"merge_requests_events": true,
"tag_push_events": true,
"note_events": true,
- "job_events": true,
+ "build_events": true,
"category": "common",
"default": false,
"wiki_page_events": true,
diff --git a/spec/lib/gitlab/import_export/relation_factory_spec.rb b/spec/lib/gitlab/import_export/relation_factory_spec.rb
index 5417c7534ea..744fed44925 100644
--- a/spec/lib/gitlab/import_export/relation_factory_spec.rb
+++ b/spec/lib/gitlab/import_export/relation_factory_spec.rb
@@ -33,7 +33,7 @@ describe Gitlab::ImportExport::RelationFactory, lib: true do
'tag_push_events' => false,
'note_events' => true,
'enable_ssl_verification' => true,
- 'job_events' => false,
+ 'build_events' => false,
'wiki_page_events' => true,
'token' => token
}
diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml
index c22fba11225..2b95f76e045 100644
--- a/spec/lib/gitlab/import_export/safe_model_attributes.yml
+++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml
@@ -292,7 +292,7 @@ Service:
- tag_push_events
- note_events
- pipeline_events
-- job_events
+- build_events
- category
- default
- wiki_page_events
@@ -312,7 +312,7 @@ ProjectHook:
- note_events
- pipeline_events
- enable_ssl_verification
-- job_events
+- build_events
- wiki_page_events
- token
- group_id
diff --git a/spec/migrations/migrate_build_events_to_pipeline_events_spec.rb b/spec/migrations/migrate_build_events_to_pipeline_events_spec.rb
new file mode 100644
index 00000000000..57eb03e3c80
--- /dev/null
+++ b/spec/migrations/migrate_build_events_to_pipeline_events_spec.rb
@@ -0,0 +1,74 @@
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20170301205640_migrate_build_events_to_pipeline_events.rb')
+
+# This migration uses multiple threads, and thus different transactions. This
+# means data created in this spec may not be visible to some threads. To work
+# around this we use the TRUNCATE cleaning strategy.
+describe MigrateBuildEventsToPipelineEvents, truncate: true do
+ let(:migration) { described_class.new }
+ let(:project_with_pipeline_service) { create(:empty_project) }
+ let(:project_with_build_service) { create(:empty_project) }
+
+ before do
+ ActiveRecord::Base.connection.execute <<-SQL
+ INSERT INTO services (properties, build_events, pipeline_events, type)
+ VALUES
+ ('{"notify_only_broken_builds":true}', true, false, 'SlackService')
+ , ('{"notify_only_broken_builds":true}', true, false, 'MattermostService')
+ , ('{"notify_only_broken_builds":true}', true, false, 'HipchatService')
+ ;
+ SQL
+
+ ActiveRecord::Base.connection.execute <<-SQL
+ INSERT INTO services
+ (properties, build_events, pipeline_events, type, project_id)
+ VALUES
+ ('{"notify_only_broken_builds":true}', true, false,
+ 'BuildsEmailService', #{project_with_pipeline_service.id})
+ , ('{"notify_only_broken_pipelines":true}', false, true,
+ 'PipelinesEmailService', #{project_with_pipeline_service.id})
+ , ('{"notify_only_broken_builds":true}', true, false,
+ 'BuildsEmailService', #{project_with_build_service.id})
+ ;
+ SQL
+ end
+
+ describe '#up' do
+ before do
+ silence_migration = Module.new do
+ # rubocop:disable Rails/Delegate
+ def execute(query)
+ connection.execute(query)
+ end
+ end
+
+ migration.extend(silence_migration)
+ migration.up
+ end
+
+ it 'migrates chat service properly' do
+ [SlackService, MattermostService, HipchatService].each do |service|
+ expect(service.count).to eq(1)
+
+ verify_service_record(service.first)
+ end
+ end
+
+ it 'migrates pipelines email service only if it has none before' do
+ Project.find_each do |project|
+ pipeline_service_count =
+ project.services.where(type: 'PipelinesEmailService').count
+
+ expect(pipeline_service_count).to eq(1)
+
+ verify_service_record(project.pipelines_email_service)
+ end
+ end
+
+ def verify_service_record(service)
+ expect(service.notify_only_broken_pipelines).to be(true)
+ expect(service.build_events).to be(false)
+ expect(service.pipeline_events).to be(true)
+ end
+ end
+end
diff --git a/spec/requests/api/project_hooks_spec.rb b/spec/requests/api/project_hooks_spec.rb
index 0f9330b062d..aee0e17a153 100644
--- a/spec/requests/api/project_hooks_spec.rb
+++ b/spec/requests/api/project_hooks_spec.rb
@@ -60,7 +60,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
expect(json_response['merge_requests_events']).to eq(hook.merge_requests_events)
expect(json_response['tag_push_events']).to eq(hook.tag_push_events)
expect(json_response['note_events']).to eq(hook.note_events)
- expect(json_response['job_events']).to eq(hook.job_events)
+ expect(json_response['job_events']).to eq(hook.build_events)
expect(json_response['pipeline_events']).to eq(hook.pipeline_events)
expect(json_response['wiki_page_events']).to eq(hook.wiki_page_events)
expect(json_response['enable_ssl_verification']).to eq(hook.enable_ssl_verification)
@@ -148,7 +148,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
expect(json_response['merge_requests_events']).to eq(hook.merge_requests_events)
expect(json_response['tag_push_events']).to eq(hook.tag_push_events)
expect(json_response['note_events']).to eq(hook.note_events)
- expect(json_response['job_events']).to eq(hook.job_events)
+ expect(json_response['job_events']).to eq(hook.build_events)
expect(json_response['pipeline_events']).to eq(hook.pipeline_events)
expect(json_response['wiki_page_events']).to eq(hook.wiki_page_events)
expect(json_response['enable_ssl_verification']).to eq(hook.enable_ssl_verification)
diff --git a/spec/requests/api/v3/project_hooks_spec.rb b/spec/requests/api/v3/project_hooks_spec.rb
index 1969d1c7f2b..a3a4c77d09d 100644
--- a/spec/requests/api/v3/project_hooks_spec.rb
+++ b/spec/requests/api/v3/project_hooks_spec.rb
@@ -58,7 +58,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
expect(json_response['merge_requests_events']).to eq(hook.merge_requests_events)
expect(json_response['tag_push_events']).to eq(hook.tag_push_events)
expect(json_response['note_events']).to eq(hook.note_events)
- expect(json_response['build_events']).to eq(hook.job_events)
+ expect(json_response['build_events']).to eq(hook.build_events)
expect(json_response['pipeline_events']).to eq(hook.pipeline_events)
expect(json_response['wiki_page_events']).to eq(hook.wiki_page_events)
expect(json_response['enable_ssl_verification']).to eq(hook.enable_ssl_verification)
@@ -143,7 +143,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
expect(json_response['merge_requests_events']).to eq(hook.merge_requests_events)
expect(json_response['tag_push_events']).to eq(hook.tag_push_events)
expect(json_response['note_events']).to eq(hook.note_events)
- expect(json_response['build_events']).to eq(hook.job_events)
+ expect(json_response['build_events']).to eq(hook.build_events)
expect(json_response['pipeline_events']).to eq(hook.pipeline_events)
expect(json_response['wiki_page_events']).to eq(hook.wiki_page_events)
expect(json_response['enable_ssl_verification']).to eq(hook.enable_ssl_verification)