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
833000ca
Commit
833000ca
authored
Jan 15, 2019
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix RSpec/FactoriesInMigrationSpecs in two files
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
99ee6c82
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
spec/migrations/add_foreign_keys_to_todos_spec.rb
spec/migrations/add_foreign_keys_to_todos_spec.rb
+4
-2
spec/migrations/cleanup_namespaceless_pending_delete_projects_spec.rb
...ons/cleanup_namespaceless_pending_delete_projects_spec.rb
+7
-5
No files found.
spec/migrations/add_foreign_keys_to_todos_spec.rb
View file @
833000ca
...
@@ -3,9 +3,11 @@ require Rails.root.join('db', 'migrate', '20180201110056_add_foreign_keys_to_tod
...
@@ -3,9 +3,11 @@ require Rails.root.join('db', 'migrate', '20180201110056_add_foreign_keys_to_tod
describe
AddForeignKeysToTodos
,
:migration
do
describe
AddForeignKeysToTodos
,
:migration
do
let
(
:todos
)
{
table
(
:todos
)
}
let
(
:todos
)
{
table
(
:todos
)
}
let
(
:users
)
{
table
(
:users
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:project
)
{
create
(
:project
)
}
# rubocop:disable RSpec/FactoriesInMigrationSpecs
let
(
:project
)
{
projects
.
create!
(
name:
'gitlab'
,
path:
'gitlab-org/gitlab-ce'
,
namespace_id:
1
)
}
let
(
:user
)
{
create
(
:user
)
}
# rubocop:disable RSpec/FactoriesInMigrationSpecs
let
(
:user
)
{
users
.
create!
(
email:
'email@email.com'
,
name:
'foo'
,
username:
'foo'
,
projects_limit:
0
)
}
context
'add foreign key on user_id'
do
context
'add foreign key on user_id'
do
let!
(
:todo_with_user
)
{
create_todo
(
user_id:
user
.
id
)
}
let!
(
:todo_with_user
)
{
create_todo
(
user_id:
user
.
id
)
}
...
...
spec/migrations/cleanup_namespaceless_pending_delete_projects_spec.rb
View file @
833000ca
...
@@ -2,6 +2,8 @@ require 'spec_helper'
...
@@ -2,6 +2,8 @@ require 'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20170502101023_cleanup_namespaceless_pending_delete_projects.rb'
)
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20170502101023_cleanup_namespaceless_pending_delete_projects.rb'
)
describe
CleanupNamespacelessPendingDeleteProjects
,
:migration
,
schema:
20180222043024
do
describe
CleanupNamespacelessPendingDeleteProjects
,
:migration
,
schema:
20180222043024
do
let
(
:projects
)
{
table
(
:projects
)
}
before
do
before
do
# Stub after_save callbacks that will fail when Project has no namespace
# Stub after_save callbacks that will fail when Project has no namespace
allow_any_instance_of
(
Project
).
to
receive
(
:ensure_storage_path_exists
).
and_return
(
nil
)
allow_any_instance_of
(
Project
).
to
receive
(
:ensure_storage_path_exists
).
and_return
(
nil
)
...
@@ -10,9 +12,9 @@ describe CleanupNamespacelessPendingDeleteProjects, :migration, schema: 20180222
...
@@ -10,9 +12,9 @@ describe CleanupNamespacelessPendingDeleteProjects, :migration, schema: 20180222
describe
'#up'
do
describe
'#up'
do
it
'only cleans up pending delete projects'
do
it
'only cleans up pending delete projects'
do
create
(
:project
)
# rubocop:disable RSpec/FactoriesInMigrationSpecs
projects
.
create!
(
name:
'gitlab'
,
path:
'gitlab-org/gitlab-ce'
,
namespace_id:
1
)
create
(
:project
,
pending_delete:
true
)
# rubocop:disable RSpec/FactoriesInMigrationSpecs
projects
.
create!
(
name:
'gitlab'
,
path:
'gitlab-org/gitlab-ee'
,
namespace_id:
2
,
pending_delete:
true
)
project
=
build
(
:project
,
pending_delete:
true
,
namespace_id:
nil
)
# rubocop:disable RSpec/FactoriesInMigrationSpecs
project
=
Project
.
new
(
pending_delete:
true
,
namespace_id:
nil
)
project
.
save
(
validate:
false
)
project
.
save
(
validate:
false
)
expect
(
NamespacelessProjectDestroyWorker
).
to
receive
(
:bulk_perform_async
).
with
([[
project
.
id
]])
expect
(
NamespacelessProjectDestroyWorker
).
to
receive
(
:bulk_perform_async
).
with
([[
project
.
id
]])
...
@@ -21,8 +23,8 @@ describe CleanupNamespacelessPendingDeleteProjects, :migration, schema: 20180222
...
@@ -21,8 +23,8 @@ describe CleanupNamespacelessPendingDeleteProjects, :migration, schema: 20180222
end
end
it
'does nothing when no pending delete projects without namespace found'
do
it
'does nothing when no pending delete projects without namespace found'
do
create
(
:project
)
# rubocop:disable RSpec/FactoriesInMigrationSpecs
projects
.
create!
(
name:
'gitlab'
,
path:
'gitlab-org/gitlab-ce'
,
namespace_id:
1
)
create
(
:project
,
pending_delete:
true
)
# rubocop:disable RSpec/FactoriesInMigrationSpecs
projects
.
create!
(
name:
'gitlab'
,
path:
'gitlab-org/gitlab-ee'
,
namespace_id:
2
,
pending_delete:
true
)
expect
(
NamespacelessProjectDestroyWorker
).
not_to
receive
(
:bulk_perform_async
)
expect
(
NamespacelessProjectDestroyWorker
).
not_to
receive
(
:bulk_perform_async
)
...
...
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