summaryrefslogtreecommitdiff
path: root/spec/migrations
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-08-17 11:54:54 +0000
committerSean McGivern <sean@mcgivern.me.uk>2017-08-17 11:54:54 +0000
commitc3e0f31dfbd1ab3f17d9acaf9cba47cfbb280c1c (patch)
tree52c70f6569c01431956b875e212983a3d5a9cd6a /spec/migrations
parentfe0ffcc78941bf9de98e3698e743c3cbb9846b6a (diff)
parent3a29646d73b7afdf2a2356c7e92ed397cc80009f (diff)
downloadgitlab-ce-c3e0f31dfbd1ab3f17d9acaf9cba47cfbb280c1c.tar.gz
Merge branch 'backstage/gb/migrations-tests-schema-version' into 'master'
Improve migrations / background migrations testing strategy Closes #36303 See merge request !13589
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/README.md10
1 files changed, 8 insertions, 2 deletions
diff --git a/spec/migrations/README.md b/spec/migrations/README.md
index 05d4f35db72..45cf25b96de 100644
--- a/spec/migrations/README.md
+++ b/spec/migrations/README.md
@@ -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
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
Use `table` helper to create a temporary `ActiveRecord::Base` derived model
@@ -80,8 +88,6 @@ end
## 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
a truncation database cleanup strategy. Do not depend on transaction being
present.