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
Léo-Paul Géneau
gitlab-ce
Commits
e2030ca0
Commit
e2030ca0
authored
Aug 16, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend migrations testing documentation
parent
c76f8f3e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
spec/migrations/README.md
spec/migrations/README.md
+8
-2
No files found.
spec/migrations/README.md
View file @
e2030ca0
...
@@ -28,6 +28,14 @@ The `after` hook will migrate the database **up** and reinstitutes the latest
...
@@ -28,6 +28,14 @@ The `after` hook will migrate the database **up** and reinstitutes the latest
schema version, so that the process does not affect subsequent specs and
schema version, so that the process does not affect subsequent specs and
ensures proper isolation.
ensures proper isolation.
## Testing a class that is not an ActiveRecord::Migration
In order to test a class that is not a migration itself, you will need to
manually provide a required schema version. Please add a
`schema`
tag to a
context that you want to switch the database schema within.
Example:
`describe SomeClass, :migration, schema: 20170608152748`
.
## Available helpers
## Available helpers
Use
`table`
helper to create a temporary
`ActiveRecord::Base`
derived model
Use
`table`
helper to create a temporary
`ActiveRecord::Base`
derived model
...
@@ -80,8 +88,6 @@ end
...
@@ -80,8 +88,6 @@ end
## Best practices
## Best practices
1.
Use only one test example per migration unless there is a good reason to
use more.
1.
Note that this type of tests do not run within the transaction, we use
1.
Note that this type of tests do not run within the transaction, we use
a truncation database cleanup strategy. Do not depend on transaction being
a truncation database cleanup strategy. Do not depend on transaction being
present.
present.
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