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
Jérome Perrin
gitlab-ce
Commits
0f9fbae7
Commit
0f9fbae7
authored
May 26, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add migrations helpers to simplify writing migration specs
parent
f7aba153
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
20 deletions
+18
-20
spec/migrations/migrate_pipeline_stages_spec.rb
spec/migrations/migrate_pipeline_stages_spec.rb
+0
-17
spec/spec_helper.rb
spec/spec_helper.rb
+3
-3
spec/support/migrations_helpers.rb
spec/support/migrations_helpers.rb
+15
-0
No files found.
spec/migrations/migrate_pipeline_stages_spec.rb
View file @
0f9fbae7
...
...
@@ -2,23 +2,6 @@ require 'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'migrate'
,
'20170525132202_migrate_pipeline_stages.rb'
)
describe
MigratePipelineStages
,
:migration
,
schema:
20170523091700
do
##
# TODO, extract to migrations helper
#
def
table
(
name
)
Class
.
new
(
ActiveRecord
::
Base
)
{
self
.
table_name
=
name
}
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
#
...
...
spec/spec_helper.rb
View file @
0f9fbae7
...
...
@@ -52,6 +52,7 @@ RSpec.configure do |config|
config
.
include
StubGitlabCalls
config
.
include
StubGitlabData
config
.
include
ApiHelpers
,
:api
config
.
include
MigrationsHelpers
,
:migration
config
.
infer_spec_type_from_file_location!
...
...
@@ -94,9 +95,8 @@ RSpec.configure do |config|
end
config
.
around
(
:example
,
migration:
true
)
do
|
example
|
schema_version
=
example
.
metadata
[
:schema
]
migrations_paths
=
ActiveRecord
::
Migrator
.
migrations_paths
ActiveRecord
::
Migrator
.
migrate
(
migrations_paths
,
schema_version
)
ActiveRecord
::
Migrator
.
migrate
(
migrations_paths
,
example
.
metadata
.
fetch
(
:schema
))
example
.
run
...
...
spec/support/migrations_helpers.rb
0 → 100644
View file @
0f9fbae7
module
MigrationsHelpers
def
table
(
name
)
Class
.
new
(
ActiveRecord
::
Base
)
{
self
.
table_name
=
name
}
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
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