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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
3e309ea7
Commit
3e309ea7
authored
Sep 28, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor migration specs using ActiveRecord models
parent
4de93b6a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
13 deletions
+18
-13
lib/gitlab/background_migration/populate_external_pipeline_source.rb
...background_migration/populate_external_pipeline_source.rb
+1
-1
spec/lib/gitlab/background_migration/populate_external_pipeline_source_spec.rb
...round_migration/populate_external_pipeline_source_spec.rb
+17
-12
No files found.
lib/gitlab/background_migration/populate_external_pipeline_source.rb
View file @
3e309ea7
...
@@ -42,7 +42,7 @@ module Gitlab
...
@@ -42,7 +42,7 @@ module Gitlab
.
where
(
.
where
(
'EXISTS (?) AND NOT EXISTS (?)'
,
'EXISTS (?) AND NOT EXISTS (?)'
,
Migratable
::
CommitStatus
.
of_type
(
'GenericCommitStatus'
).
has_pipeline
.
select
(
1
),
Migratable
::
CommitStatus
.
of_type
(
'GenericCommitStatus'
).
has_pipeline
.
select
(
1
),
Migratable
::
CommitStatus
.
of_type
(
'Ci::Build'
).
has_pipeline
.
select
(
1
)
,
Migratable
::
CommitStatus
.
of_type
(
'Ci::Build'
).
has_pipeline
.
select
(
1
)
)
)
end
end
end
end
...
...
spec/lib/gitlab/background_migration/populate_external_pipeline_source_spec.rb
View file @
3e309ea7
...
@@ -4,29 +4,34 @@ require 'spec_helper'
...
@@ -4,29 +4,34 @@ require 'spec_helper'
describe
Gitlab
::
BackgroundMigration
::
PopulateExternalPipelineSource
,
:migration
,
schema:
20180916011959
do
describe
Gitlab
::
BackgroundMigration
::
PopulateExternalPipelineSource
,
:migration
,
schema:
20180916011959
do
let
(
:migration
)
{
described_class
.
new
}
let
(
:migration
)
{
described_class
.
new
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:pipelines
)
{
table
(
:ci_pipelines
)
}
let
(
:statuses
)
{
table
(
:ci_builds
)
}
let
(
:builds
)
{
table
(
:ci_builds
)
}
let!
(
:internal_pipeline
)
{
pipelines
.
create
(
id:
1
,
source:
described_class
::
Migratable
::
Pipeline
.
sources
[
:web
])
}
let!
(
:internal_pipeline
)
{
create
(
:ci_pipeline
,
source:
Ci
::
Pipeline
.
sources
[
:web
])
}
let!
(
:external_pipeline
)
{
pipelines
.
create
(
id:
2
,
source:
nil
)
}
let!
(
:external_pipeline
)
do
let!
(
:second_external_pipeline
)
{
pipelines
.
create
(
id:
3
,
source:
nil
)
}
build
(
:ci_pipeline
,
source:
Ci
::
Pipeline
.
sources
[
:unknown
])
let!
(
:status
)
{
statuses
.
create
(
id:
1
,
commit_id:
2
,
type:
'GenericCommitStatus'
)
}
.
tap
{
|
pipeline
|
pipeline
.
save
(
validate:
false
)
}
let!
(
:build
)
{
builds
.
create
(
id:
2
,
commit_id:
1
,
type:
'Ci::Build'
)
}
end
let!
(
:second_external_pipeline
)
do
build
(
:ci_pipeline
,
source:
Ci
::
Pipeline
.
sources
[
:unknown
])
.
tap
{
|
pipeline
|
pipeline
.
save
(
validate:
false
)
}
end
before
do
create
(
:generic_commit_status
,
pipeline:
external_pipeline
)
create
(
:ci_build
,
pipeline:
internal_pipeline
)
end
subject
{
migration
.
perform
(
1
,
2
)
}
subject
{
migration
.
perform
(
external_pipeline
.
id
,
second_external_pipeline
.
id
)
}
it
'populates the pipeline source'
do
it
'populates the pipeline source'
do
subject
subject
expect
(
external_pipeline
.
reload
.
source
).
to
eq
(
described_class
::
Migratable
::
Pipeline
.
sources
[
:external
]
)
expect
(
external_pipeline
.
reload
.
source
).
to
eq
(
'external'
)
end
end
it
'only processes a single batch of links at a time'
do
it
'only processes a single batch of links at a time'
do
subject
subject
expect
(
second_external_pipeline
.
reload
.
source
).
to
eq
(
nil
)
expect
(
second_external_pipeline
.
reload
.
source
).
to
eq
(
'unknown'
)
end
end
it
'can be repeated without effect'
do
it
'can be repeated without effect'
do
...
...
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