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
0aa33c7a
Commit
0aa33c7a
authored
Oct 30, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use insert_all in specs
Look for active services only
parent
9d6b948c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
db/migrate/20201027002551_migrate_services_to_http_integrations.rb
...e/20201027002551_migrate_services_to_http_integrations.rb
+11
-4
spec/migrations/20201027002551_migrate_services_to_http_integrations_spec.rb
...01027002551_migrate_services_to_http_integrations_spec.rb
+1
-1
No files found.
db/migrate/20201027002551_migrate_services_to_http_integrations.rb
View file @
0aa33c7a
...
...
@@ -24,18 +24,25 @@ class MigrateServicesToHttpIntegrations < ActiveRecord::Migration[6.0]
JOIN alerts_service_data
ON (services.id = alerts_service_data.service_id)
WHERE type = '
#{
ALERT_SERVICE_TYPE
}
'
AND active = TRUE
SQL
select_all
(
sql
).
each
do
|
alerts_service
|
HttpIntegration
.
create!
(
current_time
=
Time
.
current
values
=
select_all
(
sql
).
map
do
|
alerts_service
|
{
project_id:
alerts_service
[
'project_id'
],
name:
SERVICE_NAMES_IDENTIFIER
[
:name
],
endpoint_identifier:
SERVICE_NAMES_IDENTIFIER
[
:identifier
],
encrypted_token:
alerts_service
[
'encrypted_token'
],
encrypted_token_iv:
alerts_service
[
'encrypted_token_iv'
],
active:
alerts_service
[
'active'
]
)
active:
alerts_service
[
'active'
],
updated_at:
current_time
,
created_at:
current_time
}
end
HttpIntegration
.
insert_all
(
values
)
if
values
.
present?
end
def
down
...
...
spec/migrations/20201027002551_migrate_services_to_http_integrations_spec.rb
View file @
0aa33c7a
...
...
@@ -6,7 +6,7 @@ require Rails.root.join('db', 'migrate', '20201027002551_migrate_services_to_htt
RSpec
.
describe
MigrateServicesToHttpIntegrations
do
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
)
{
table
(
:services
).
create!
(
type:
'AlertsService'
,
project_id:
project
.
id
,
active:
true
)
}
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
)
}
...
...
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