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
f7aba153
Commit
f7aba153
authored
May 26, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make migration specs by using migrator in around hook
parent
acc22a84
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
3 deletions
+16
-3
spec/migrations/migrate_pipeline_stages_spec.rb
spec/migrations/migrate_pipeline_stages_spec.rb
+15
-2
spec/spec_helper.rb
spec/spec_helper.rb
+1
-1
No files found.
spec/migrations/migrate_pipeline_stages_spec.rb
View file @
f7aba153
...
@@ -2,10 +2,23 @@ require 'spec_helper'
...
@@ -2,10 +2,23 @@ require 'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'migrate'
,
'20170525132202_migrate_pipeline_stages.rb'
)
require
Rails
.
root
.
join
(
'db'
,
'migrate'
,
'20170525132202_migrate_pipeline_stages.rb'
)
describe
MigratePipelineStages
,
:migration
,
schema:
20170523091700
do
describe
MigratePipelineStages
,
:migration
,
schema:
20170523091700
do
##
# TODO, extract to migrations helper
#
def
table
(
name
)
def
table
(
name
)
Class
.
new
(
ActiveRecord
::
Base
)
{
self
.
table_name
=
name
}
Class
.
new
(
ActiveRecord
::
Base
)
{
self
.
table_name
=
name
}
end
end
def
migrations_paths
ActiveRecord
::
Migrator
.
migrations_paths
end
def
migrate!
ActiveRecord
::
Migrator
.
up
(
migrations_paths
)
do
|
migration
|
migration
.
name
==
described_class
.
name
end
end
##
##
# Create test data
# Create test data
#
#
...
@@ -13,10 +26,10 @@ describe MigratePipelineStages, :migration, schema: 20170523091700 do
...
@@ -13,10 +26,10 @@ describe MigratePipelineStages, :migration, schema: 20170523091700 do
table
(
:ci_pipelines
).
create!
(
ref:
'master'
,
sha:
'adf43c3a'
)
table
(
:ci_pipelines
).
create!
(
ref:
'master'
,
sha:
'adf43c3a'
)
end
end
it
'correctly migrates pipeline stages'
do
it
'correctly migrates pipeline stages'
do
|
migration
,
meta
|
expect
(
ActiveRecord
::
Base
.
connection
.
table_exists?
(
'ci_stages'
)).
to
eq
false
expect
(
ActiveRecord
::
Base
.
connection
.
table_exists?
(
'ci_stages'
)).
to
eq
false
described_class
.
new
.
migrate
(
:up
)
migrate!
expect
(
ActiveRecord
::
Base
.
connection
.
table_exists?
(
'ci_stages'
)).
to
eq
true
expect
(
ActiveRecord
::
Base
.
connection
.
table_exists?
(
'ci_stages'
)).
to
eq
true
end
end
...
...
spec/spec_helper.rb
View file @
f7aba153
...
@@ -100,7 +100,7 @@ RSpec.configure do |config|
...
@@ -100,7 +100,7 @@ RSpec.configure do |config|
example
.
run
example
.
run
ActiveRecord
::
Migrat
ion
.
maintain_test_schema!
ActiveRecord
::
Migrat
or
.
migrate
(
migrations_paths
)
end
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