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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
171eab81
Commit
171eab81
authored
Apr 10, 2017
by
blackst0ne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for schema.rb
parent
01adf920
Changes
2
Hide 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 @
171eab81
---
title
:
Add spec for schema.rb
merge_request
:
10580
author
:
blackst0ne
spec/migrations/schema_spec.rb
0 → 100644
View file @
171eab81
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