Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1a21f2c6
Commit
1a21f2c6
authored
Oct 28, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add down method for migration
- Add specs - update! -> update
parent
0dba4721
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
7 deletions
+31
-7
app/services/alert_management/sync_alert_service_data_service.rb
...vices/alert_management/sync_alert_service_data_service.rb
+1
-1
db/migrate/20201027002551_migrate_services_to_http_integrations.rb
...e/20201027002551_migrate_services_to_http_integrations.rb
+10
-1
spec/migrations/20201027002551_migrate_services_to_http_integrations_spec.rb
...01027002551_migrate_services_to_http_integrations_spec.rb
+20
-5
No files found.
app/services/alert_management/sync_alert_service_data_service.rb
View file @
1a21f2c6
...
...
@@ -30,7 +30,7 @@ module AlertManagement
end
def
update_integration_data
(
http_integration
)
http_integration
.
update
!
(
http_integration
.
update
(
active:
alert_service
.
active
,
encrypted_token:
alert_service
.
data
.
encrypted_token
,
encrypted_token_iv:
alert_service
.
data
.
encrypted_token_iv
...
...
db/migrate/20201027002551_migrate_services_to_http_integrations.rb
View file @
1a21f2c6
...
...
@@ -42,6 +42,15 @@ class MigrateServicesToHttpIntegrations < ActiveRecord::Migration[6.0]
end
def
down
# NO-OP
sql
=
<<~
SQL
SELECT project_id FROM services
WHERE type = '
#{
ALERT_SERVICE_TYPE
}
'
SQL
select_values
(
sql
).
each
do
|
project_id
|
HttpIntegration
.
where
(
project_id:
project_id
,
endpoint_identifier:
SERVICE_NAMES_IDENTIFIER
[
:identifier
])
.
delete_all
end
end
end
spec/migrations/20201027002551_migrate_services_to_http_integrations_spec.rb
View file @
1a21f2c6
...
...
@@ -4,11 +4,10 @@ require 'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'migrate'
,
'20201027002551_migrate_services_to_http_integrations.rb'
)
RSpec
.
describe
MigrateServicesToHttpIntegrations
do
let_it_be
(
:namespace
)
{
table
(
:namespaces
).
create!
(
name:
'namespace'
,
path:
'namespace'
)
}
let_it_be
(
:project
)
{
table
(
:projects
).
create!
(
id:
1
,
namespace_id:
namespace
.
id
)
}
let_it_be
(
:alert_service
)
{
table
(
:services
).
create
(
type:
'AlertsService'
,
project_id:
project
.
id
)}
let_it_be
(
:alert_service_data
)
{
table
(
:alerts_service_data
).
create
(
service_id:
alert_service
.
id
,
encrypted_token:
'test'
,
encrypted_token_iv:
'test'
)}
let!
(
:namespace
)
{
table
(
:namespaces
).
create!
(
name:
'namespace'
,
path:
'namespace'
)
}
let!
(
:project
)
{
table
(
:projects
).
create!
(
id:
1
,
namespace_id:
namespace
.
id
)
}
let!
(
:alert_service
)
{
table
(
:services
).
create!
(
type:
'AlertsService'
,
project_id:
project
.
id
)
}
let!
(
:alert_service_data
)
{
table
(
:alerts_service_data
).
create!
(
service_id:
alert_service
.
id
,
encrypted_token:
'test'
,
encrypted_token_iv:
'test'
)}
let
(
:http_integrations
)
{
table
(
:alert_management_http_integrations
)
}
describe
'#up'
do
...
...
@@ -24,4 +23,20 @@ RSpec.describe MigrateServicesToHttpIntegrations do
expect
(
http_integration
.
endpoint_identifier
).
to
eq
(
described_class
::
SERVICE_NAMES_IDENTIFIER
[
:identifier
])
end
end
describe
'#down'
do
before
do
http_integrations
.
create!
(
project_id:
project
.
id
,
name:
described_class
::
SERVICE_NAMES_IDENTIFIER
[
:name
],
endpoint_identifier:
described_class
::
SERVICE_NAMES_IDENTIFIER
[
:identifier
],
encrypted_token:
'test'
,
encrypted_token_iv:
'test'
)
end
it
'removes the existing http integrations'
do
expect
{
described_class
.
new
.
down
}.
to
change
{
http_integrations
.
count
}.
from
(
1
).
to
(
0
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment