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
9a8ea266
Commit
9a8ea266
authored
Apr 10, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'spec_for_schema' into 'master'
Add spec for schema.rb Closes #21978 See merge request !10580
parents
ce6a48cb
171eab81
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
changelogs/unreleased/spec_for_schema.yml
changelogs/unreleased/spec_for_schema.yml
+4
-0
spec/migrations/schema_spec.rb
spec/migrations/schema_spec.rb
+23
-0
No files found.
changelogs/unreleased/spec_for_schema.yml
0 → 100644
View file @
9a8ea266
---
title
:
Add spec for schema.rb
merge_request
:
10580
author
:
blackst0ne
spec/migrations/schema_spec.rb
0 → 100644
View file @
9a8ea266
require
'spec_helper'
# Check consistency of db/schema.rb version, migrations' timestamps, and the latest migration timestamp
# stored in the database's schema_migrations table.
describe
ActiveRecord
::
Schema
do
let
(
:latest_migration_timestamp
)
do
migrations
=
Dir
[
Rails
.
root
.
join
(
'db'
,
'migrate'
,
'*'
),
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'*'
)]
migrations
.
map
{
|
migration
|
File
.
basename
(
migration
).
split
(
'_'
).
first
.
to_i
}.
max
end
it
'> schema version equals last migration timestamp'
do
defined_schema_version
=
File
.
open
(
Rails
.
root
.
join
(
'db'
,
'schema.rb'
))
do
|
file
|
file
.
find
{
|
line
|
line
=~
/ActiveRecord::Schema.define/
}
end
.
match
(
/(\d+)/
)[
0
].
to_i
expect
(
defined_schema_version
).
to
eq
(
latest_migration_timestamp
)
end
it
'> schema version should equal the latest migration timestamp stored in schema_migrations table'
do
expect
(
latest_migration_timestamp
).
to
eq
(
ActiveRecord
::
Migrator
.
current_version
.
to_i
)
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